Skip to content

P3: Fix data loss and crashes in the mission editors (FRED and qtFRED) - #8028

Open
dustinspace217 wants to merge 11 commits into
scp-fs2open:masterfrom
dustinspace217:fix/editor-data-loss-and-crashes
Open

dustinspace217 wants to merge 11 commits into
scp-fs2open:masterfrom
dustinspace217:fix/editor-data-loss-and-crashes

Conversation

@dustinspace217

@dustinspace217 dustinspace217 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What?

Six small fixes to the mission editors, one commit each.

Both editors:

  • Saving a mission dropped its gravity setting and the hide-in-mission-log ship flag.
  • Deleting a mission goal or a cutscene left the deleted entry as the current one. qtFRED crashed on the next keystroke in the name box. FRED kept the fields live when no row was left, and typing there changed a different goal.

qtFRED only:

  • Events editor: pressing OK without touching anything reset a repeat count of -1 to 1 and cleared the first message's persona and team. Cancel asked about changes when there were none.
  • Mission goals: Objective Invalid and Don't Play Completion Music did nothing.
  • Team loadout: the skip-validation setting was never loaded, so the next OK cleared it.
  • Special stats: every OK also wrote the values to the first ship in the mission.

Why?

Most of these change or lose a mission designer's work with no message. They turned up while comparing qtFRED with FRED dialog by dialog: open a dialog, press OK without touching anything, save, and compare the file.

How?

Each fix is a few lines. The qtFRED fixes follow what FRED does. The FRED delete fix uses the reset FRED's events editor already does when an event is deleted. After a delete, FRED follows the row its tree selects next; qtFRED leaves nothing selected.

Testing?

  • Each bug was reproduced first, on master 8ef44a4 (qtFRED Debug, Linux) or on the official 26.2.0 FRED build (Windows 11), then rechecked on builds of this branch: qtFRED on Linux, FRED built with MSVC.
  • MediaVPs 5.0.2 and a new test mod holding copies of SM1-01 with the fields under test added by hand.
  • FRED: goal and cutscene delete, and the gravity and flag round trip.
  • Master and branch save sm3-09, MT-01 and SM2-03 identically.
  • Debug and Release build without warnings on Linux, and the unit tests pass.
  • No automated tests: the editors have no test target for dialogs, and no existing test saves a mission.
  • Not run in FRED: team loadout and special stats, which are qtFRED-only changes.

Anything Else?

  • Backport the QtFRED Undo System #8017 touches 8 of these 13 files and already fixes the two goal checkboxes, the persona reset and the false changes prompt in its own way. I can drop those parts or rebase after it, whichever is easier.
  • Left alone: +Pbank Ammo is still not saved. It is in FRED too.
  • The selection group fix that was here is now covered by Various fixes for qtFRED #8030, which fixes it in both editors, so I took it out to avoid a conflict.
  • I wrote this with help from Claude Code.

The mission parser reads $Gravity Acceleration and the hide-in-mission-log ship flag, but the save code never wrote them, so FRED and qtFRED both dropped them the first time a mission was saved. They are now written the same way as their neighbours: gravity after the sound environment, and the flag in the +Flags2 list.
…age's persona and team

Opening the events editor and pressing OK without touching anything changed three things. An event with a repeat count of -1 (repeat forever) was reset to 1, because the editor treated every count below 1 as unset; only 0 means unset, as in FRED and in the mission parser. The first message lost its persona and its team, because filling each of those lists selected its first entry and that was stored on the message.

Cancelling the untouched editor also asked whether to keep changes, because filling the message fields from the mission ran their edit handlers. Those no longer run while the fields are being filled.
Ticking All Teams at War in the flag list only set a mission flag that nothing reads. The game and the save code use Mission_all_attack, which the dialog wrote back unchanged, so the saved mission had no +All Teams Attack line and the teams were not at war. The checkbox now starts from Mission_all_attack and is written back to it. The flag itself is no longer stored, so the mission is saved the way FRED saves it: the +All Teams Attack line and no flag bit.
After a goal was deleted, both editors kept the deleted goal's slot as the current goal. In qtFRED, typing in the name box then dereferenced a null tree item and crashed. In FRED, when no row was left for the tree to select, the fields stayed filled and enabled, and editing them wrote to whichever goal had moved into that slot (one hidden by the display type filter, for example) or past the end of the list. Deleting a goal now clears the current goal in both editors. FRED then follows the row its tree selects next, if there is one; qtFRED leaves nothing selected.

Also in qtFRED: the Objective Invalid and Don't Play Completion Music checkboxes had handlers whose signature matched no checkbox signal, so Qt never connected them and ticking either one changed nothing. The completion music box also read the wrong field when a goal was selected.
…eted

The same fault as in the mission goals editors: after a cutscene was deleted, both editors kept its slot as the current cutscene. qtFRED crashed on the next keystroke in the filename box. FRED left the type and filename fields filled and enabled when no row was left to select. Deleting a cutscene now clears the current cutscene in both editors. FRED then follows the row its tree selects next, if there is one; qtFRED leaves nothing selected.
The dialog saved Skip FRED's Weapon Loadout Validation but never read it back, so the box was always unticked when the dialog opened and the next OK cleared the setting. It is now read from the team data, as FRED does.
Set Group and Group used the group number 1 to 9 as the bit mask itself, so group 3 was groups 1 and 2 together, and setting it cleared ships out of those two. FRED uses one bit per group (1 << n), which is also what a saved mission's +Group value means. qtFRED now does the same.
The dialog kept its list of selected ships in a vector sized for every possible ship, filled only the first few entries, and then applied the values to all of them. The unused entries were zero, so every OK also wrote the special hitpoints, shields and explosion settings to ship 0, which is usually the player. The list now holds only the selected ships, and the separate count that indexed it is gone.

@Goober5000 Goober5000 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd split the All Teams At War fix into a separate PR. That PR should convert the global variable to a mission flag, similar to what was done for +Scramble: and +Red Alert:.

It moves to its own pull request, which stores the setting as a mission flag, as asked in the review.

This reverts commit 93e7767.
A ship's group field is a set of bits, one per editor group, and 0 means no group. Ship creation set it to 0 until 2013 and the mission parser did until 2022; both now start at -1, which has every bit set. A ship placed in the editor, or loaded from a mission with no +Group line, therefore answered to every group, and its group was never saved because the save code skips negative values. Both defaults are 0 again, and the two comments describe the field as it is used.

A mission that has no +Group lines gains "+Group: 0" on every ship the next time it is saved, the form retail missions such as SM1-01 already have.
@dustinspace217

Copy link
Copy Markdown
Contributor Author

Makes sense. I'll take All Teams at War out of this PR and redo it in its own PR as a mission flag, the way +Scramble: and +Red Alert: work. I also added one commit here so ships placed in the editor start with no group; it goes with the group fix already in this PR.

This reverts ec05013 and f3afffd. scp-fs2open#8030 fixes the same selection group bug in both editors with shared helpers that keep -1 for "no group", so saved missions do not change. Dropping this version avoids a conflict in FredView.cpp.
@dustinspace217

Copy link
Copy Markdown
Contributor Author

The mission flag version is up as #8031.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants