From 2777a2f1285afd4a54c428d13d8ea74db375bb56 Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Wed, 11 Nov 2026 06:18:53 -0800 Subject: [PATCH 01/11] qtFRED wing editor: keep the arrival distance when the arrival target changes Changing a wing's arrival target set its arrival distance to 0 whenever the distance was larger than the new target's minimum, because the comparison was the wrong way round. The box went on showing the minimum, and the pre-save check then reported that the distance must be greater than 0. A distance below the minimum was left as it was. The distance is now raised to the minimum only when it is below it, as the arrival location handler a few lines up already does. --- qtfred/src/mission/dialogs/WingEditorDialogModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp b/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp index 38ab3537d58..f45111a074b 100644 --- a/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp +++ b/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp @@ -1009,8 +1009,8 @@ void WingEditorDialogModel::setArrivalTarget(int targetIndex) // Set the distance to minimum if current is smaller int minDistance = getMinArrivalDistance(); - if (minDistance < w->arrival_distance) { - setArrivalDistance(0); + if (w->arrival_distance < minDistance) { + setArrivalDistance(minDistance); } modify(w->arrival_path_mask, 0); From d8dce195ccf17d41b833d586c4efa3419d3716b8 Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Wed, 11 Nov 2026 06:18:55 -0800 Subject: [PATCH 02/11] qtFRED fiction viewer editor: clearing the story file removes only the first stage The dialog edits the first fiction viewer stage, but a mission file can hold several. Clearing the story file and pressing OK deleted all of them. Only the first stage is removed now. --- qtfred/src/mission/dialogs/FictionViewerDialogModel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qtfred/src/mission/dialogs/FictionViewerDialogModel.cpp b/qtfred/src/mission/dialogs/FictionViewerDialogModel.cpp index f8fede9b783..6044b3ea802 100644 --- a/qtfred/src/mission/dialogs/FictionViewerDialogModel.cpp +++ b/qtfred/src/mission/dialogs/FictionViewerDialogModel.cpp @@ -16,7 +16,8 @@ bool FictionViewerDialogModel::apply() { const bool empty = stage.story_filename[0] == '\0'; if (empty) { - _fictionViewerStages.clear(); + // only the first stage is edited here, so only it goes; a mission can carry more + _fictionViewerStages.erase(_fictionViewerStages.begin()); Mission_music[SCORE_FICTION_VIEWER] = -1; } else { // Keep whatever you've edited in _fictionViewerStages From f73b4c873cd44878b84544f31b3bcf18f345432d Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Wed, 11 Nov 2026 06:42:41 -0800 Subject: [PATCH 03/11] qtFRED variables editor: save a variable's new type when it is changed Changing a variable from number to string kept the number bit it was loaded with and added the string bit. The save code tests the number bit first, so the variable was written with its text value and the type "number". The old type bits are now cleared before the type chosen in the dialog is set. The team loadout reads the variables it uses by type when a mission loads, so with the type really saved, a changed one stopped the mission from loading. OK now refuses a type change for a variable the team loadout uses, which FRED's variable dialog refuses as well. --- qtfred/src/mission/dialogs/VariableDialogModel.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qtfred/src/mission/dialogs/VariableDialogModel.cpp b/qtfred/src/mission/dialogs/VariableDialogModel.cpp index fe04994b987..144d8b21712 100644 --- a/qtfred/src/mission/dialogs/VariableDialogModel.cpp +++ b/qtfred/src/mission/dialogs/VariableDialogModel.cpp @@ -1,5 +1,6 @@ #include "VariableDialogModel.h" +#include "missioneditor/sexp_tree_model.h" #include "parse/sexp.h" #include @@ -50,7 +51,8 @@ bool VariableDialogModel::apply() renamedVariables.emplace_back(i, var_info.originalName); } strcpy_s(Sexp_variables[i].variable_name, var_info.name.c_str()); - Sexp_variables[i].type = var_info.flags; + // the stored flags still hold the type the variable was loaded with; the dialog's type is set below + Sexp_variables[i].type = var_info.flags & ~(SEXP_VARIABLE_NUMBER | SEXP_VARIABLE_STRING); if (var_info.is_string) { strcpy_s(Sexp_variables[i].text, var_info.stringValue.c_str()); @@ -67,7 +69,7 @@ bool VariableDialogModel::apply() // New variable if (!found) { - int flags = var_info.flags; + int flags = var_info.flags & ~(SEXP_VARIABLE_NUMBER | SEXP_VARIABLE_STRING); const char* value_str; SCP_string num_val_str; @@ -238,6 +240,14 @@ bool VariableDialogModel::checkValidity() if (!names_taken.insert(var.name).second) { error_message += "Duplicate variable name found: \"" + var.name + "\"\n"; } + + // the team loadout reads its variables by type, and a mission saved with the wrong one does not load + const int idx = var.originalName.empty() ? -1 : get_index_sexp_variable_name(var.originalName.c_str()); + if (idx >= 0 && var.is_string != ((Sexp_variables[idx].type & SEXP_VARIABLE_STRING) != 0) && + SexpTreeModel::get_loadout_variable_count(idx) > 0) { + error_message += + "The type of variable \"" + var.name + "\" cannot change while the team loadout uses it.\n"; + } } if (m_variables.size() > MAX_SEXP_VARIABLES) { From dbc95bf7728a1f4c055e411a39317236bd03f9b9 Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Wed, 11 Nov 2026 06:42:41 -0800 Subject: [PATCH 04/11] qtFRED toolbar Rename: refuse names the ship editor refuses, and leave wing members alone The Rename button on the selection toolbar passed whatever was typed straight to the rename code. A name already used by another ship was accepted, which also pointed that ship's references in events and goals at the shared name. A name of 32 or more characters hit the length assert in Debug and did not fit the ship's name field. The first is refused now by the ship editor's name check, the second by a length check. The button was also offered for a wing member, whose name comes from its wing. Renaming one left the wing with a ship the pre-save check reports as an error. A wing member no longer gets the button. --- qtfred/src/ui/FredView.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/qtfred/src/ui/FredView.cpp b/qtfred/src/ui/FredView.cpp index a17fef0d342..9987618e46a 100644 --- a/qtfred/src/ui/FredView.cpp +++ b/qtfred/src/ui/FredView.cpp @@ -1180,7 +1180,8 @@ void FredView::onUpdateContextToolbar() { const bool anythingSelected = valid || numMarked > 0; if (effectiveIsShip) { - if (numMarked <= 1) + // a wing member is named by its wing, so it gets no Rename + if (numMarked <= 1 && !effectiveInWing) addBtn(tr("Rename"), &FredView::quickRenameCurrentObject); addBtn(tr("Edit Ship"), &FredView::on_actionShips_triggered); if (effectiveInWing) { @@ -1220,7 +1221,17 @@ void FredView::quickRenameCurrentObject() { if (!ok || newName.isEmpty() || newName == current) return; if (Objects[obj].type == OBJ_SHIP || Objects[obj].type == OBJ_START) { - fred->rename_ship(Objects[obj].instance, newName.toUtf8().constData()); + // the ship editor refuses these names as well, and a longer one does not fit the ship's name field + const SCP_string name = newName.toUtf8().constData(); + SCP_string reason = check_name_conflict("ship", name.c_str(), Objects[obj].instance); + if (reason.empty() && name.size() >= NAME_LENGTH) { + reason = "This ship name is too long"; + } + if (!reason.empty()) { + showButtonDialog(DialogType::Error, "Ship Name Error", reason, { DialogButton::Ok }); + return; + } + fred->rename_ship(Objects[obj].instance, name.c_str()); } // Waypoints, props, and jump nodes open their editor (name field is front-and-center) // Wing rename goes through Edit Wing since wings have no standalone scene object From 0c4628cc96851f19465fdf21a1d05871e577981f Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Wed, 11 Nov 2026 12:48:36 -0800 Subject: [PATCH 05/11] qtFRED ship editor: keep a custom display name when the ship name is not changed Clicking into the Ship Name box and leaving it without typing reset a custom display name, and the next save lost it. So did a rename the editor refused, such as another ship's name. The display name is now reset only when the ship's name really changes. --- qtfred/src/ui/dialogs/ShipEditor/ShipEditorDialog.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/qtfred/src/ui/dialogs/ShipEditor/ShipEditorDialog.cpp b/qtfred/src/ui/dialogs/ShipEditor/ShipEditorDialog.cpp index 0f649313f4c..1a4a94fceb9 100644 --- a/qtfred/src/ui/dialogs/ShipEditor/ShipEditorDialog.cpp +++ b/qtfred/src/ui/dialogs/ShipEditor/ShipEditorDialog.cpp @@ -768,11 +768,14 @@ void ShipEditorDialog::on_shipNameEdit_editingFinished() if (!entry.isEmpty() && entry != _model->getShipName().c_str()) { const auto textBytes = entry.toUtf8(); const std::string NewShipName = textBytes.toStdString(); + const SCP_string oldShipName = _model->getShipName(); _model->setShipName(NewShipName); - } - // automatically determine or reset the display name - _model->setShipDisplayName(Editor::get_display_name_for_text_box(_model->getShipName())); + // a refused rename leaves the ship name as it was, and its display name with it + if (_model->getShipName() != oldShipName) { + _model->setShipDisplayName(Editor::get_display_name_for_text_box(_model->getShipName())); + } + } // sync the variable to the edit box ui->shipDisplayNameEdit->setText(_model->getShipDisplayName().c_str()); From 1c6d20749d9a0b57a0d0720e87822fbb153dc24f Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Wed, 11 Nov 2026 12:36:09 -0800 Subject: [PATCH 06/11] qtFRED variables editor: keep values right when two variables trade names OK looked each variable up by its old name while earlier ones in the same pass had already been renamed. When two variables traded names, both found the same one: it ended up with the second variable's value and flags, and the first variable's value was lost. Every variable is now looked up before any is renamed. --- .../mission/dialogs/VariableDialogModel.cpp | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/qtfred/src/mission/dialogs/VariableDialogModel.cpp b/qtfred/src/mission/dialogs/VariableDialogModel.cpp index 144d8b21712..707492de2ea 100644 --- a/qtfred/src/mission/dialogs/VariableDialogModel.cpp +++ b/qtfred/src/mission/dialogs/VariableDialogModel.cpp @@ -41,34 +41,41 @@ bool VariableDialogModel::apply() } } - for (const auto& var_info : m_variables) { - bool found = false; - // Existing variable that might be modified or deleted - if (!var_info.originalName.empty()) { + // find every existing variable by its old name before any is renamed, or two variables that swap names + // would both find the first one + SCP_vector existing_index(m_variables.size(), -1); + for (size_t v = 0; v < m_variables.size(); ++v) { + if (!m_variables[v].originalName.empty()) { for (int i = 0; i < MAX_SEXP_VARIABLES; ++i) { - if (!stricmp(Sexp_variables[i].variable_name, var_info.originalName.c_str())) { - if (var_info.name != var_info.originalName) { - renamedVariables.emplace_back(i, var_info.originalName); - } - strcpy_s(Sexp_variables[i].variable_name, var_info.name.c_str()); - // the stored flags still hold the type the variable was loaded with; the dialog's type is set below - Sexp_variables[i].type = var_info.flags & ~(SEXP_VARIABLE_NUMBER | SEXP_VARIABLE_STRING); - - if (var_info.is_string) { - strcpy_s(Sexp_variables[i].text, var_info.stringValue.c_str()); - Sexp_variables[i].type |= SEXP_VARIABLE_STRING; - } else { - strcpy_s(Sexp_variables[i].text, std::to_string(var_info.numberValue).c_str()); - Sexp_variables[i].type |= SEXP_VARIABLE_NUMBER; - } - found = true; + if (!stricmp(Sexp_variables[i].variable_name, m_variables[v].originalName.c_str())) { + existing_index[v] = i; break; } } } + } + + for (size_t v = 0; v < m_variables.size(); ++v) { + const auto& var_info = m_variables[v]; + const int i = existing_index[v]; + // Existing variable that might be modified + if (i >= 0) { + if (var_info.name != var_info.originalName) { + renamedVariables.emplace_back(i, var_info.originalName); + } + strcpy_s(Sexp_variables[i].variable_name, var_info.name.c_str()); + // the stored flags still hold the type the variable was loaded with; the dialog's type is set below + Sexp_variables[i].type = var_info.flags & ~(SEXP_VARIABLE_NUMBER | SEXP_VARIABLE_STRING); - // New variable - if (!found) { + if (var_info.is_string) { + strcpy_s(Sexp_variables[i].text, var_info.stringValue.c_str()); + Sexp_variables[i].type |= SEXP_VARIABLE_STRING; + } else { + strcpy_s(Sexp_variables[i].text, std::to_string(var_info.numberValue).c_str()); + Sexp_variables[i].type |= SEXP_VARIABLE_NUMBER; + } + } else { + // New variable int flags = var_info.flags & ~(SEXP_VARIABLE_NUMBER | SEXP_VARIABLE_STRING); const char* value_str; SCP_string num_val_str; From 6c0f698c80c1f2d184b8367f767ff33c2a03b2f0 Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Wed, 11 Nov 2026 13:13:55 -0800 Subject: [PATCH 07/11] qtFRED variables editor: carry a variable rename to events and the team loadout Events, cues and the team loadout refer to a variable by name, and renaming one in the variables editor left them on the old name. An event then saved the variable as undefined, and a team loadout count or class saved with a name that no longer existed, which hit an assert while saving in Debug. OK now renames those references in the mission as well, the same way container renames already reach events. An event editor that is open at the time keeps its own copy and still writes the old name back when it is closed with OK, as it does for container renames. --- .../mission/dialogs/VariableDialogModel.cpp | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/qtfred/src/mission/dialogs/VariableDialogModel.cpp b/qtfred/src/mission/dialogs/VariableDialogModel.cpp index 707492de2ea..fcefde81ff5 100644 --- a/qtfred/src/mission/dialogs/VariableDialogModel.cpp +++ b/qtfred/src/mission/dialogs/VariableDialogModel.cpp @@ -1,5 +1,6 @@ #include "VariableDialogModel.h" +#include "mission/missionparse.h" #include "missioneditor/sexp_tree_model.h" #include "parse/sexp.h" @@ -92,6 +93,41 @@ bool VariableDialogModel::apply() } } + // events, cues and the team loadout refer to a variable by name, so a rename has to reach them too + if (!renamedVariables.empty()) { + SCP_unordered_map new_names; + for (const auto& renamed : renamedVariables) { + new_names[renamed.second] = Sexp_variables[renamed.first].variable_name; + } + + for (int i = 0; i < Num_sexp_nodes; i++) { + auto& node = Sexp_nodes[i]; + if (node.type & SEXP_FLAG_VARIABLE) { + const auto it = new_names.find(node.text); + if (it != new_names.cend()) { + strcpy_s(node.text, it->second.c_str()); + } + } + } + + const auto follow_rename = [&new_names](SCP_string& name) { + const auto it = new_names.find(name); + if (it != new_names.cend()) { + name = it->second; + } + }; + for (auto& team : Team_data) { + for (auto& entry : team.ship_choices) { + follow_rename(entry.class_variable); + follow_rename(entry.count_variable); + } + for (auto& entry : team.weapon_choices) { + follow_rename(entry.class_variable); + follow_rename(entry.count_variable); + } + } + } + // Apply Container Changes SCP_vector new_containers; SCP_unordered_map renamed_containers; From d7f7ff52204ecba75bd6575df0b49fb74e25e862 Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Wed, 11 Nov 2026 12:58:14 -0800 Subject: [PATCH 08/11] qtFRED variables editor: find each variable by its exact name OK found variables by name without regard to case, and also matched slots whose variable was already deleted, since a deleted slot keeps its name. In a mission with both Cancer and cancer, OK with nothing changed saved cancer's value under both names and lost Cancer's, and deleting cancer deleted nothing. After deleting a variable and giving its name to another in one OK, the next OK brought the deleted one back as a second variable of that name. Variables are now found with the engine's own lookup, which matches the exact name among the variables in use, as the game and the save code do. --- .../src/mission/dialogs/VariableDialogModel.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/qtfred/src/mission/dialogs/VariableDialogModel.cpp b/qtfred/src/mission/dialogs/VariableDialogModel.cpp index fcefde81ff5..c62856fc47d 100644 --- a/qtfred/src/mission/dialogs/VariableDialogModel.cpp +++ b/qtfred/src/mission/dialogs/VariableDialogModel.cpp @@ -34,11 +34,9 @@ bool VariableDialogModel::apply() // Loop through our new list of deleted variables and remove them from the global state. for (const auto& original_name : m_deleted_variables) { - for (int i = 0; i < MAX_SEXP_VARIABLES; ++i) { - if (!stricmp(Sexp_variables[i].variable_name, original_name.c_str())) { - sexp_variable_delete(i); - break; - } + const int i = get_index_sexp_variable_name(original_name.c_str()); + if (i >= 0) { + sexp_variable_delete(i); } } @@ -47,12 +45,7 @@ bool VariableDialogModel::apply() SCP_vector existing_index(m_variables.size(), -1); for (size_t v = 0; v < m_variables.size(); ++v) { if (!m_variables[v].originalName.empty()) { - for (int i = 0; i < MAX_SEXP_VARIABLES; ++i) { - if (!stricmp(Sexp_variables[i].variable_name, m_variables[v].originalName.c_str())) { - existing_index[v] = i; - break; - } - } + existing_index[v] = get_index_sexp_variable_name(m_variables[v].originalName.c_str()); } } From 4203f77122d2be605649c7e16c6e00ef4ddcceb6 Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Wed, 11 Nov 2026 12:55:30 -0800 Subject: [PATCH 09/11] qtFRED wing editor: keep a custom display name when the wing name is not changed Leaving the Wing Name box without changing it still renamed the wing to its own name, which resets the display name, and the dialog then showed in the Display Name box. Tabbing on through that box saved , and the custom display name was lost. The wing is now renamed only when its name really changes, and the Display Name box is only refreshed then, as FRED does. --- qtfred/src/mission/dialogs/WingEditorDialogModel.cpp | 4 ++++ qtfred/src/ui/dialogs/WingEditorDialog.cpp | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp b/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp index f45111a074b..6cf2bcf848a 100644 --- a/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp +++ b/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp @@ -451,6 +451,10 @@ void WingEditorDialogModel::setWingName(const SCP_string& name) if (!wingIsValid()) return; + // rename_wing resets the display name, so it only runs for a real rename + if (name == _currentWingName) + return; + if (_editor->rename_wing(_currentWingIndex, name)) { modify(_currentWingName, name); Q_EMIT modelChanged(); diff --git a/qtfred/src/ui/dialogs/WingEditorDialog.cpp b/qtfred/src/ui/dialogs/WingEditorDialog.cpp index 5bb423f4bf5..c1290d02bbf 100644 --- a/qtfred/src/ui/dialogs/WingEditorDialog.cpp +++ b/qtfred/src/ui/dialogs/WingEditorDialog.cpp @@ -405,10 +405,13 @@ void WingEditorDialog::on_hideCuesButton_clicked() void WingEditorDialog::on_wingNameEdit_editingFinished() { const auto newName = ui->wingNameEdit->text().toStdString(); + const SCP_string oldName = _model->getWingName(); _model->setWingName(newName); // rename_wing already auto-sets the display name from the hash; just sync the edit box - ui->wingDisplayNameEdit->setText(Editor::get_display_name_for_text_box(_model->getWingName()).c_str()); + if (_model->getWingName() != oldName) { + ui->wingDisplayNameEdit->setText(Editor::get_display_name_for_text_box(_model->getWingName()).c_str()); + } } void WingEditorDialog::on_wingDisplayNameEdit_editingFinished() From c8db74a5ac31e5f0d87c7d18ac938b4125634ccc Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Wed, 11 Nov 2026 13:24:47 -0800 Subject: [PATCH 10/11] FRED: carry a variable rename to events and the team loadout FRED renamed a variable only in the sexp tree it was renamed from. Events and cues held elsewhere, and the team loadout, which refers to a variable by name, stayed on the old name. After a rename from a wing's cue, saving showed "Couldn't find variable" warnings for the events and the file was not written. After a rename of a ship pool count variable, the next save (the autosave when the events editor closed) hit an assert in Debug builds; Release reads before the start of the variable list there. The reference update that qtFRED gained in the previous commits now sits beside the loadout counter in the shared editor code, and both editors call it. --- code/missioneditor/sexp_tree_model.cpp | 33 +++++++++++++++++++ code/missioneditor/sexp_tree_model.h | 2 ++ fred2/sexp_tree_view.cpp | 1 + .../mission/dialogs/VariableDialogModel.cpp | 28 +--------------- 4 files changed, 37 insertions(+), 27 deletions(-) diff --git a/code/missioneditor/sexp_tree_model.cpp b/code/missioneditor/sexp_tree_model.cpp index 7e45afc5b89..7a5e396e2c7 100644 --- a/code/missioneditor/sexp_tree_model.cpp +++ b/code/missioneditor/sexp_tree_model.cpp @@ -1175,6 +1175,39 @@ int SexpTreeModel::get_loadout_variable_count(int var_index) return count; } +void SexpTreeModel::rename_variable_references(const SCP_unordered_map& new_names) +{ + // all renames are looked up in one pass, so two variables that trade names do not collide + for (int i = 0; i < Num_sexp_nodes; i++) { + auto& node = Sexp_nodes[i]; + if (node.type & SEXP_FLAG_VARIABLE) { + const auto it = new_names.find(node.text); + if (it != new_names.cend()) { + strcpy_s(node.text, it->second.c_str()); + } + } + } + + const auto follow_rename = [&new_names](SCP_string& name) { + const auto it = new_names.find(name); + if (it != new_names.cend()) { + name = it->second; + } + }; + + for (auto& team_datum : Team_data) { + for (auto& entry : team_datum.ship_choices) { + follow_rename(entry.class_variable); + follow_rename(entry.count_variable); + } + + for (auto& entry : team_datum.weapon_choices) { + follow_rename(entry.class_variable); + follow_rename(entry.count_variable); + } + } +} + // Count how many tree nodes are container name or container data references // matching the given container_name. int SexpTreeModel::get_container_usage_count(const SCP_string& container_name) const diff --git a/code/missioneditor/sexp_tree_model.h b/code/missioneditor/sexp_tree_model.h index 1a2fb7b8003..0314af9542d 100644 --- a/code/missioneditor/sexp_tree_model.h +++ b/code/missioneditor/sexp_tree_model.h @@ -573,6 +573,8 @@ class SexpTreeModel { int get_variable_count(const char* var_name) const; // Count how many times a variable is used in player loadout data (Team_data) static int get_loadout_variable_count(int var_index); + // Point every sexp node and loadout entry naming a renamed variable (old name -> new name) at its new name + static void rename_variable_references(const SCP_unordered_map& new_names); // Count how many tree nodes reference the given container name int get_container_usage_count(const SCP_string& container_name) const; // Check if a specific node is a valid, matching container reference for the given name diff --git a/fred2/sexp_tree_view.cpp b/fred2/sexp_tree_view.cpp index 35f3ae1e7ab..9372feff0fa 100644 --- a/fred2/sexp_tree_view.cpp +++ b/fred2/sexp_tree_view.cpp @@ -921,6 +921,7 @@ BOOL sexp_tree_view::OnCommand(WPARAM wParam, LPARAM lParam) // Don't sort until after modify, since modify uses index if (dlg.m_modified_name) { + SexpTreeModel::rename_variable_references({{old_name, Sexp_variables[sexp_var_index].variable_name}}); sexp_variable_sort(); } diff --git a/qtfred/src/mission/dialogs/VariableDialogModel.cpp b/qtfred/src/mission/dialogs/VariableDialogModel.cpp index c62856fc47d..96a1beae7d9 100644 --- a/qtfred/src/mission/dialogs/VariableDialogModel.cpp +++ b/qtfred/src/mission/dialogs/VariableDialogModel.cpp @@ -1,6 +1,5 @@ #include "VariableDialogModel.h" -#include "mission/missionparse.h" #include "missioneditor/sexp_tree_model.h" #include "parse/sexp.h" @@ -93,32 +92,7 @@ bool VariableDialogModel::apply() new_names[renamed.second] = Sexp_variables[renamed.first].variable_name; } - for (int i = 0; i < Num_sexp_nodes; i++) { - auto& node = Sexp_nodes[i]; - if (node.type & SEXP_FLAG_VARIABLE) { - const auto it = new_names.find(node.text); - if (it != new_names.cend()) { - strcpy_s(node.text, it->second.c_str()); - } - } - } - - const auto follow_rename = [&new_names](SCP_string& name) { - const auto it = new_names.find(name); - if (it != new_names.cend()) { - name = it->second; - } - }; - for (auto& team : Team_data) { - for (auto& entry : team.ship_choices) { - follow_rename(entry.class_variable); - follow_rename(entry.count_variable); - } - for (auto& entry : team.weapon_choices) { - follow_rename(entry.class_variable); - follow_rename(entry.count_variable); - } - } + SexpTreeModel::rename_variable_references(new_names); } // Apply Container Changes From e08153dd635e85a70aecb9cd942597115f80b9c4 Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Wed, 11 Nov 2026 23:35:14 -0800 Subject: [PATCH 11/11] Take the wing arrival distance change out of this pull request This reverts 2777a2f12. #8030 makes the same change to WingEditorDialogModel::setArrivalTarget and also shares the minimum distance rule between the editors, so this copy is no longer needed. --- qtfred/src/mission/dialogs/WingEditorDialogModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp b/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp index 6cf2bcf848a..3ff6c08e856 100644 --- a/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp +++ b/qtfred/src/mission/dialogs/WingEditorDialogModel.cpp @@ -1013,8 +1013,8 @@ void WingEditorDialogModel::setArrivalTarget(int targetIndex) // Set the distance to minimum if current is smaller int minDistance = getMinArrivalDistance(); - if (w->arrival_distance < minDistance) { - setArrivalDistance(minDistance); + if (minDistance < w->arrival_distance) { + setArrivalDistance(0); } modify(w->arrival_path_mask, 0);