Repository navigation
Conversation
dustinspace217
left a comment
There was a problem hiding this comment.
Thanks for these. I built master and this branch and ran qtFRED and the game on both.
What I could reproduce on master and saw fixed here:
- Initial Status with two marked ships (SM3-06, Nebtuu and Lambda 2): master shows hull 100 instead of "-" and crashes on OK inside ShipInitialStatusDialogModel::apply(). Here both fields show "-", OK works, and each ship keeps its own velocity and hull in the saved file.
- Selection groups (SM3-10, which has ships saved with +Group: 1, 2 and 4): Ctrl+3 marks 27 ships on master (groups 1 and 2) and the 7 ships in group 3 here.
Regression: opened and saved SM1-01, SM2-01, SM3-06, SM3-10, Training-3 and TSM-104 (MediaVPs 5.0.2) in both builds, and the saved files are identical apart from the timestamp. Game side: SM2-01 into gameplay and a clean exit on OpenGL and Vulkan, master vs this branch, with no new log warnings. Unit tests match master.
Not reproduced: the exit crash (master Debug and an ASan build both exit cleanly with the Events and Reinforcements editors open), the campaign graph assert (needs a debug Qt), and the Lua AI goal cleanup (no retail content uses Lua AI modes). The autosave, Save As, template, failed save and FS1 import changes I checked by reading only, and they look right. FRED2 is Windows only, so I couldn't run it; CI's MSVC jobs build it.
Two things need a change, both inline: the clang-tidy finding that turned CI red, and FRED2's ship editor still using the old arrival distance rule.
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.
This reverts 2777a2f. scp-fs2open#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.
78492ee to
9023734
Compare
dustinspace217
left a comment
There was a problem hiding this comment.
Thanks for turning both requests around: setSpinBoxValueOrBlank is static and FRED2's ship editor calls arrival_min_distance(). This round I built the branch (Release and Debug, 346 unit tests pass) and took SM2-01 into gameplay and out to a clean exit on OpenGL and Vulkan with this branch and master; all four exited with code 0 and no log problems. qtFRED wasn't built this round, so the editor points below are from reading the code.
Two things I'd like changed:
The autosave gate at qtfred/src/ui/FredView.cpp:288 assumes every edit sets _missionModified, but the Reinforcements, Mission Specs, Variables, Briefing and Asteroid models and onSetGroup() never emit missionChanged(), so an edit made only there now gets no autosave where master wrote one every interval. The gate also keeps a stale autosave after Revert or Discard, so the next open offers back the discarded changes; dropping the gate and deleting the mission's autosave after a successful save, on Revert and on Discard would fix both.
In MixedValueSpinBox.cpp:17 the mixed state sets the value to INT_MIN, and as I read it, Enter on an untouched "-" field emits that value (or the clamped minimum if Qt goes through valueFromText), which the Initial Status and Reinforcements slots pass straight to the model, where apply only skips 101. I couldn't run it to confirm the Qt side, but ignoring the mixed sentinel in those slots would keep each ship's own value either way.
Smaller:
- fred2/wing_editor.cpp:733 is still on the old rule (no minimum for special anchors, truncation, negative distances kept), so item 10 and the comment at shipeditordlg.cpp:1289 aren't true yet; calling arrival_min_distance() there finishes it.
- fred2/shipeditordlg.cpp:1290 casts m_arrival_location, which is -1 when the marked ships have different arrival locations, so nothing is clamped; each ship's own arrival_location and anchor would fix it.
- ShipEditorDialogModel.cpp:1217 checks only the last marked ship's distance and then writes the minimum to every marked ship, and the new call at :1165 adds a location change as a trigger; raising each ship only when its own distance is too low fixes it.
- code/missioneditor/common.cpp:147 leaves a ship at group 0 after its last bit is removed, and the save then writes +Group: 0; setting it back to -1 avoids that.
- missionsave.cpp:2457 ignores the cf_rename results, so the new failed-save message can't see a failed replace with backups off; that predates this PR, so a follow-up is fine.
- The new rules in common.cpp and the Lua goal handler have no tests; a small file next to test_object_bounds.cpp plus one that calls Script_system.Clear() with goal arguments set would pin them.
- Autosaves written by older builds use the plain file name, so they're never offered again and stay in the folder; a fallback lookup or a note in the description would cover it.
- Nits: arrival_location_uses_distance sits under get_special_anchor's doc comment (missionparse.cpp:8971), askToUseNewerAutosave is under private slots, mission_load_error is unused, the exit comment at FredView.cpp:2268 could mention Cancel at the mission prompt, and the description could say old qtFRED group numbers now read as bit masks.
|
Thanks for the second review. I made the changes in six commits, from 6a7cf07 to 53ab2da. Autosave (FredView.cpp:288). I removed the gate. The timer writes an autosave at each interval again, the same as on master, so the Reinforcements, Mission Specs, Variables, Briefing and Asteroid editors need no change. A successful save, Revert, and Discard now delete the autosave of the mission. Save As also deletes the autosave of the old path or of the untitled mission. After a save, the interval starts again from zero. One case stays the same as on master: if you save and then do nothing for more than one interval, the next open offers an autosave with the same content. MixedValueSpinBox. You read it correctly. For "-", Arrival distance.
Smaller items.
Tests. The build passes with |
dustinspace217
left a comment
There was a problem hiding this comment.
Thanks, everything from the second review is in. I built this head (Release and Debug, no warnings, 360 and 358 unit tests pass) and ran the three editor cases you could not run, in qtFRED on Linux with a copy of SM1-01:
- Enter on a "-" field: Initial Status with two ships marked, Enter on the Hull field. Each ship kept its own hull and velocity in the saved file.
- Autosave: written at each interval; gone after Save, after Revert, and after Discard at File > New. Reopening the mission showed no recovery prompt.
- Arrival distance: two ships marked, one at 2000 and one at 30, then a new target whose minimum is 117. One warning, the first ship stayed at 2000 and the second went to 117.
The inline notes are about the new code. None of them blocks; the first one is the one I would look at before this merges.
Two small things I saw in those runs: after the "Value has been reset to this" box, the distance field still shows the old number (0, or 30 with two ships marked) while the saved value is right. And untitled_autosave.fs2 stays in the autosave folder after opening another mission from an untitled one.
Not run by anyone: the two FRED2 editors.
One overlap to know about: my #8039 also changes FredView::closeEvent and loadMissionFile. It closes the registered tool dialogs before the prompt and reopens them if the quit is cancelled; yours closes every editor window and deletes them before shutdown. The two fit together (mine first for the registered tools, then your loop for the rest, then your delete), and I will do that merge in #8039 once this lands.
Goober5000
left a comment
There was a problem hiding this comment.
A few more notes on the current head. None of them repeat dustinspace217's comments.
|
Thanks for the third round, and thanks for the editor runs. I applied the notes from dustinspace217, Goober5000 and Kestrellius in four commits, from c8650f4 to 3adc13e. Mission save ( Autosave timer. Revert and Discard now stop the timer. The next mission load or new mission starts it again. If the FS1 import is cancelled at a file dialog after a Discard, the timer starts again for the open mission. The untitled autosave is deleted when another mission loads. Recovered autosave path ( Ship editor distance (QtFRED). The distance field is now a Wing editors.
FRED2 ship editor. Tests.
Verification. The build passes with |
dustinspace217
left a comment
There was a problem hiding this comment.
Re-checked at 3adc13e. My four notes are all fixed: a failed final rename now returns an error and keeps the autosave, Revert and Discard stop the timer, the FRED2 wing editor check is outside the target block, and the 100.2 case tells round from ceil.
On your question about the stale distance field: from reading this head, I think it's still there. The field only gets its value in updateUi() (ShipEditorDialog.cpp:337-339). That runs when the dialog opens and on shipMarkingChanged. modelChanged only calls initializeUi() (line 57), which never sets the field. So when a target or location change raises a ship, or leaves the marked ships with different distances, the field keeps the old number until the marking changes. The saved values are right. In the mixed case the field also shows one real number instead of "-", so typing that same number back sends no change. Refreshing the distance field after a change that raises or mixes the distances should fix it. I haven't rerun the editor at this head.
Minor: on Windows with backups off, the old file is deleted before the rename, so if the rename then fails, the mission file is missing until the next save. The edits stay in the editor, still marked modified, so another save can write them. A rename that replaces the existing file would close that gap.
QtFRED gave the group numbers 1 to 9 to the group functions as bit masks. Thus group 3 was the same as groups 1 and 2. Also, a ship in no group has the value -1, and -1 has all bits set. Such a ship matched each group in QtFRED and FRED2. Each group is now one bit, the same as in FRED2. The new shared functions ship_in_editor_group() and ship_set_editor_group() hold the meaning of -1, and QtFRED and FRED2 both use them. A ship in no group keeps -1, so the mission save writes no group data for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the user chose a new arrival target, the wing editor set the arrival distance to 0, because the comparison was reversed. The save check then failed with "Arrival distance for wing ... must be greater than 0". The distance now stays. The editor raises it to the minimum for the new target only if it is smaller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wing editor and the ship editor each had their own copy of the minimum arrival distance, and the copies were wrong in two ways: - With a special anchor such as "<any friendly>", both editors accepted a distance of 0. The mission parser changes 0 to 1, and the error checker rejects it. - The ship editor took the radius of the marked arriving ships. FRED2 and the wing editor take the radius of the target ship. arrival_location_uses_distance() in missionparse now gives the locations near a ship. The parser, the error checker, and both models use it. arrival_min_distance() in the shared editor code gives the minimum: 0 for a location without a distance, at least 1 otherwise, and min(500, 2 * target radius) near a real ship. The ship editor also checks the distance when the arrival location changes, and it does not accept negative distances. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Initial Status and Reinforcements dialogs show "-" in a spin box when the marked objects have different values. Two defects: - In the Initial Status dialog, the "-" text stayed after the box got a real value, so a real value at the minimum (for example a velocity of 0) also showed "-". - A typed value equal to the value under the "-" did not change the spin box, so Qt sent no signal and the dialog ignored the value. The new widget MixedValueSpinBox (a QSpinBox subclass) keeps the mixed state and the real minimum in members. setMixed() moves the minimum below the real range, so each value that the user enters is a change. The widget keeps typed values and arrow steps in the real range. setSingleValue() ends the mixed state. Both dialogs use the widget as a promoted widget, and the clamp code in the Reinforcements slots is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With several ships marked, OK in the Initial Status dialog damaged the ships: - The code checked the velocity flag three times and never used the shield and hull flags. So mixed values did not show blank, and OK wrote 101 (the blank marker) to the ships. - OK gave the guardian threshold and the team color of one ship to all marked ships. - OK could crash, because the dock update ran in multi-edit mode, where the dock data was never set up. Now a field with different values shows blank, and OK keeps the value of each ship for a blank field. This includes the guardian threshold and the team color. The team color goes only to ships that use team colors. The dock update runs only when the dialog edits one ship. The multi-edit loop uses one ship reference and one merge function for the check boxes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The goals of Lua AI modes keep Lua values (the extra SEXP arguments) in Ai_info and Wings. Script_system.Clear() closes the Lua state, but these values stayed. Their destructors ran later, for example at program exit, and released references in the closed Lua state. The new ai_lua_init() in ailua.cpp registers an OnStateDestroy handler that frees these arguments while the Lua state still exists. ai_init() calls it once. This applies to the game and to the editors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QtFRED freed the mission and SEXP data while editor windows still used it, because WA_DeleteOnClose deletes a window only after shutdown(). QtFRED and FRED2 also never closed the Lua scripting system. Closing the campaign editor could trigger the Qt assert "Called object is not of the correct type", because the graph scene sent selectionChanged to the half-destroyed graph. On exit, QtFRED now closes the editor windows first, so each one can ask about its own changes. After the mission prompt, it deletes them, then it shuts down the engine. The new shared editor_shutdown() frees the engine and SEXP data, closes the Lua state (in the same order as game_shutdown()), then sound, then graphics. QtFRED and FRED2 both use it, and FRED2 no longer closes sound in CFREDView::OnDestroy. The campaign editor and its graph disconnect their child signals in their destructors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each update of the recent-files menu created up to 8 new menu actions with the main window as parent. QMenu::clear() did not delete them, so they leaked. The menu now owns its actions. The update removes the old actions and deletes them later, because a recent-file action can start the update while it sends its own triggered() signal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three defects in the save path: - After Save As, the window title still showed the old file name. - A cancelled Save As cleared the current file name, because the dialog result went directly into the member. - A template load kept the save path of the mission that was open before, so Save wrote over that mission. A .fst file opened from the recent-files list or with -start_mission loaded as a plain mission, so Save wrote over the template. Editor now holds the save path. Editor::loadMission() makes each .fst file a template and gives a template no save path. FredView::saveName is removed; FredView reads Editor::currentMissionPath(). Save As uses a local variable, sets the new path only after the save, and updates the title and the recent-files list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The FS1 import loads the .fsm file and then saves it as an FS2 mission. The load made the .fsm file the save path. If the conversion save failed, the mission stayed loaded, and Save wrote FS2 data over the FS1 source file. An FS1 import now gives an untitled mission. After a successful conversion, the import loads the converted file as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Several defects in the autosave recovery: - After a recovery, the save path pointed to the file in the autosave folder, so Save wrote there. On Windows, the '/' separators from QStandardPaths could trigger the CFile assert "We have full path, but no separator!?". - Two missions with the same file name in different folders shared one autosave, so the recovery could load the wrong mission. - The timer wrote an autosave also without unsaved changes. The next load then offered a recovery of content that was already in the file, and Revert could bring back the changes that the user had just discarded. Editor::loadMission() now owns the recovery. It asks about a newer autosave, loads it with native separators, and keeps the original mission path as the save path. missionLoaded() tells FredView that the content is not saved yet, so the mission shows as modified. A failed load gives an untitled mission. The autosave name contains a hash of the full mission path. The timer writes an autosave only for unsaved changes, and Revert does not offer a recovery. The dead catch block in loadMissionFile() is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
save_mission_file() only writes to the log when it fails. Save and Save As ignored its result: they cleared the modified flag and set the last-saved time also after a failure. The user saw no message, and QtFRED then closed without a prompt, so the edits were lost. The new writeMissionFile() checks the result. On failure, it shows an error and keeps the modified flag. Save As then also keeps the old file name. configureMissionSave() now sets the save options in one place for Save, the autosave, and the FS1 import, and reportPreSaveFixes() shows the pre-save check result for Save and Save As. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The function does not use this. The clang-tidy job reports it as readability-convert-member-functions-to-static. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The ship editor used the radius of the arriving ship and accepted a distance of 0 for a special anchor. The wing editors and QtFRED use the radius of the target. Use the shared rule so the editors agree. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The autosave gate needed the modified flag. The Reinforcements, Mission Specs, Variables, Briefing, and Asteroid editors do not set it, so an edit in only these editors got no autosave. The gate also kept a stale autosave after Revert or Discard, and the next load offered the discarded changes again. Write the autosave at each interval, the same as before. A successful save, Revert, and Discard now delete the autosave of the mission. Save As also deletes the autosave of the old path. After a save, the interval starts again. askToUseNewerAutosave() is no longer a slot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the mixed state, the value of the spin box is a sentinel below the real range. Enter on an untouched "-" field went through valueFromText(), which clamped "-" to the real minimum. The slots then gave that value to the model, so each marked ship got it. valueFromText() now keeps "-" as the sentinel. The new isBlank() tells the Initial Status and Reinforcements slots to ignore the sentinel, so each ship keeps its own value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The QtFRED ship editor examined only the distance of the last marked ship, and then wrote its minimum to each marked ship. It also examined the target before it wrote the new target to the ships. FRED2's ship editor used the dialog's arrival location, which is -1 when the marked ships have different locations, so it did no check. FRED2's wing editor still used the old rule. Each ship and wing now gets the minimum for its own location and target, and a ship with a sufficient distance keeps it. A negative distance goes up to the minimum, because the parser changes a value of 0 or less to 1. In multi-edit mode, FRED2 does not write the minimum of one ship into the field, because save() copies the field to each ship. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ship stayed at group 0 after its last group bit was removed, and the
mission save then wrote "+Group: 0". Set it back to -1 ("in no group").
QtFRED's Set Group also marks the mission as changed now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The new editor tests examine the group bits and arrival_min_distance(). The Lua test puts Lua values into the AI goal arguments, calls Script_system.Clear(), and makes sure that the arguments are empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the doc comment of get_special_anchor() back to its function. Remove the unused mission_load_error. Mention Cancel at the mission prompt in the exit comment. Make the recent-files loop variable const, for misc-const-correctness. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mission save ignored the result of the last rename. On Windows with backups off, rename() does not replace a file that exists, so the save did not change the mission file. Delete the old file first on Windows, and return an error if the rename fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The timer could write the discarded changes again while a dialog stayed open. The next load starts the timer again. A plain Save now deletes the autosave one time only. The untitled autosave is deleted when another mission loads. A recovered autosave now uses the absolute mission path, the same as a normal load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- QtFRED ship editor: the distance field shows "-" when the marked ships have different distances, and its maximum is no longer 99. - QtFRED wing editor: with no targets, the distance gets the minimum. - FRED2 wing editor: the minimum check also runs with no target. - FRED2 ship editor: one warning after all the ships, and only when bypass_errors is not set. - Correct the comment of MIN_TARGET_ARRIVAL_DISTANCE. It is the largest minimum, not a lower limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A radius of 100.2 tells round from ceil. ai_lua_init() adds a handler to the global Script_system, so call it only one time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The distance field got its value only when the dialog opened or the marking changed. When a target or location change raised a ship to its minimum, or left the marked ships with different distances, the field kept the old number. The saved values were correct. The dialog now refreshes the distance field after each model change. It changes the field only when the field shows a different value. The field also sends its value only on Enter or focus loss. Before, each key press sent a value, so the minimum check could raise a part of a typed number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Windows with backups off, the save deleted the old mission file and then renamed the temporary file. If that rename failed, the mission file was missing until the next save. cf_rename() has a new replace_existing parameter. On Windows it uses MoveFileExA() with MOVEFILE_REPLACE_EXISTING. POSIX rename() already replaces a file. The mission save uses it, so a failed rename keeps the old mission file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3adc13e to
179b098
Compare
This PR fixes several issues that were never reported to the SCP. They are based on the description of fixes in the OFP fork, but no code from OFP was used in development; these are clean-slate reimplementations.
Full list of included changes:
Crashes and data loss
the mission that was open before.
Editor behavior
Restructuring (no behavior change)
Compatibility notes
Tests
Follow-ups (not in this PR)
🤖 Generated with Claude Code