Skip to content

add a Reorder Ships and Wings editor to FRED#7515

Open
Goober5000 wants to merge 4 commits into
scp-fs2open:masterfrom
Goober5000:feature/reorder_ships_wings
Open

add a Reorder Ships and Wings editor to FRED#7515
Goober5000 wants to merge 4 commits into
scp-fs2open:masterfrom
Goober5000:feature/reorder_ships_wings

Conversation

@Goober5000

@Goober5000 Goober5000 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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.

@Goober5000 Goober5000 added fred A feature or issue related to the FReespace EDitor (FRED) Waiting for Stable Marks a pull request that is to be merged after the next stable release, due to a release cycle feature A totally new sort of functionality labels Jun 11, 2026
@Goober5000 Goober5000 force-pushed the feature/reorder_ships_wings branch 5 times, most recently from 78b2b93 to 230ce66 Compare June 16, 2026 03:39
@BMagnu BMagnu removed the Waiting for Stable Marks a pull request that is to be merged after the next stable release, due to a release cycle label Jul 5, 2026
@Goober5000 Goober5000 marked this pull request as draft July 11, 2026 23:16
@Goober5000 Goober5000 force-pushed the feature/reorder_ships_wings branch 4 times, most recently from 376d1d3 to 25e94da Compare July 12, 2026 23:59
@Goober5000 Goober5000 marked this pull request as ready for review July 13, 2026 01:37
Goober5000 and others added 4 commits July 12, 2026 21:38
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>
@Goober5000 Goober5000 force-pushed the feature/reorder_ships_wings branch from 25e94da to 84b10ea Compare July 13, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A totally new sort of functionality fred A feature or issue related to the FReespace EDitor (FRED)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants