Skip to content

fix move semantics for data loaded from .tbl and .tbm files#7608

Open
Goober5000 wants to merge 3 commits into
scp-fs2open:masterfrom
Goober5000:fix/vector_movable_collections
Open

fix move semantics for data loaded from .tbl and .tbm files#7608
Goober5000 wants to merge 3 commits into
scp-fs2open:masterfrom
Goober5000:fix/vector_movable_collections

Conversation

@Goober5000

Copy link
Copy Markdown
Contributor

Fortunately, most types implemented move semantics correctly (usually because the moves were defaulted), but there were three that needed work:

  • built-in messages
  • ship_info
  • glowpoint overrides

This PR fixes all three.

Goober5000 and others added 3 commits July 13, 2026 14:45
The defaulted moves copied the conditionally-owned name and its
ownership flag without clearing the source, so reallocation of
Builtin_messages (mods append custom types via #Message Types) freed
every strdup'd name out from under the surviving elements.  Hand-write
the moves to reset the source and free the destination's old name.
Also fix copy-assignment, which leaked the old name and was unsafe
under self-assignment.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The hand-written ~350-line memberwise move existed only to manage the
one raw owning pointer, and silently left any member it didn't mention
uninitialized in the destination.  With subsystems as a unique_ptr, the
defaulted moves and destructor are correct by composition.  Copies
become explicitly deleted (use clone()).  n_subsystems stays a plain
int because it is passed to varargs functions.  The moves are not
declared noexcept because libstdc++ computes a potentially-throwing
implicit specification; NOLINT suppresses clang-tidy accordingly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
glowpoint_bank_override_map stored raw pointers into the growable global glowpoint_bank_overrides vector.  Store indices instead, which survive vector reallocation.  The readers also lose a redundant second map lookup (they previously called find() and then operator[] on the same key), and prop_info's parallel map gets the same conversion.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Goober5000 Goober5000 added the fix A fix for bugs, not-a-bugs, and/or regressions. label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant