add a Reorder Ships and Wings editor to FRED#7515
Open
Goober5000 wants to merge 4 commits into
Open
Conversation
78b2b93 to
230ce66
Compare
376d1d3 to
25e94da
Compare
Ship's implicit move operations compiled but were semantically broken in two ways: moving copied the subsys_list sentinel's links verbatim, leaving the bookend nodes of the intrusive subsystem list pointing at the old sentinel address; and the raw owning warpin_effect / warpout_effect pointers were copied without nulling the source, so a vacated Ships[] slot aliased live WarpEffects that ship::clear() (on slot reuse) or ship_close() (which walks every slot) would delete out from under the destination ship. Fix both at the member level so the compiler-generated moves are correct by composition: - Add ship_subsys_sentinel, derived from ship_subsys, whose move operations re-link the bookend nodes (handling the null-linked, self-referential-empty, and populated source states) and leave the moved-from sentinel as an initialized empty list. Copying is deleted. Public inheritance keeps &ship::subsys_list convertible to ship_subsys*, so list_init, GET_FIRST, and every other call site is unchanged. - Convert warpin_effect and warpout_effect to std::unique_ptr. The delete-and-null blocks in ship::clear(), ship_close(), and ship_set_warp_effects() collapse into reset(); call sites that borrow the pointer into a raw local now use get(). With the members handling themselves, declare ship's special member functions: defaulted default constructor and moves, deleted copies (previously implicit via the unique_ptr members, now stated intent). The moves are deliberately not declared noexcept because members like SCP_map and std::deque do not have standard-guaranteed nothrow moves; the computed exception specification is used instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
reassign_ship_slot moves a ship between Ships[] slots, fixing up every back-reference: Objects[].instance, Ai_info[].shipnum, Wings[].ship_index[], Player_start_shipnum, Ship_registry's cached shipnum, and the FRED-side parallel arrays Fred_alt_names/Fred_callsigns plus cur_ship (passed via FredShipSlotConfig so non-FRED callers can opt out). swap_ship_slots wraps it as a three-leg swap through a temporary empty slot. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
reassign_wing_slot moves a wing between Wings[] slots, fixing up every back-reference: Ships[i].wingnum, the Starting/Squadron/TVT_wings caches (via update_custom_wing_indexes), the FRED-side parallel array wing_objects, and cur_wing (passed via FredWingSlotConfig so non-FRED callers can opt out). swap_wing_slots wraps it as a three-leg swap through a temporary empty slot. Also consolidates update_custom_wing_indexes (previously duplicated verbatim in fred2/management.cpp and qtfred Editor) into common.cpp so the new utility — and any future caller — has one shared implementation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Accessible from the Tools menu, this dialog lists all ships or all wings (selectable via a drop-down) and provides Move to top/up/down/ bottom buttons. Moves are applied immediately via the slot reassignment utilities in missioneditor/common.h, using adjacent swaps so the relative order of other entries is preserved. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
25e94da to
84b10ea
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accessible from the Tools menu, this dialog lists all ships or all wings (selectable via a drop-down) and provides Move to top/up/down/bottom buttons. Moves are applied immediately via the slot reassignment utilities in missioneditor/common.h, using adjacent swaps so the relative order of other entries is preserved.
(Fixes ship move operations in the process, as moving was broken in several ways. This will also be beneficial for future conversion of ships to use SCP_vector.)
Currently FRED-only but could be extended to QtFRED easily.
In draft as it depends on #7578.