Commit Graph
935 Commits
Author SHA1 Message Date
Goober5000 b532a7b855 properly initialize each reinforcement 2026-05-26 10:55:05 -04:00
Goober5000 7545e5d035 make the reinforcements collection dynamic
As requested by a FREDder who has a plausible situation where more than 32 reinforcements might be handy. :)
2026-05-26 10:55:05 -04:00
Goober5000 70c4010389 add wing display names (#7429)
* add wing display names

Adds display name capability for wings, matching the pattern and infrastructure of display names for ships.  As in #7234, wing display names take precedence over ship display names, if both are provided; because if ship display names took precedence, a ship would have the same display name in every wave.

All the relevant display locations are handled, including the HUD, escort list, message box, and mission log.  Lua API support is provided as well.

Adds full support for both FRED and QtFRED, including the always-save-display-names setting.

Addresses #7189 and the last request from #1730.

* add help text from #7234
2026-05-20 15:16:08 -04:00
Goober5000 ef73e2572d unlimited mission titles
Some code refactoring to allow mission titles to be strings of any length.  Titles that are too long to actually display (based on string width) will be visibly truncated using `font::force_fit_string`, but the underlying title will not be affected.  Multiplayer is still subject to the 31-character length limit, so titles sent over the network will still have characters truncated.

Also removes some redundant calls to `gr_get_string_size`, since `font::force_fit_string` returns the fitted string width.
2026-05-12 11:31:20 -04:00
Mike Nelson 975ce277a7 QtFRED large ship collision group mission flag (#7425)
* large ship collision group mission flag

* update help doc
2026-05-12 07:51:00 -04:00
Mike Nelson 6c0d490489 Qtfred error checker (#7389)
* new qtfred error checker

* fix some issues

* clang

* more clang

* clean up and fixes

* missed a comment

* add help documentation

* surface auto corrected issues more clearly

* some cleanup
2026-05-12 07:49:27 -04:00
Goober5000andClaude Opus 4.6 3f85d6172a use std::move() for local variables that are copied but not reused (#7308)
* use std::move() for local variables that are copied but not reused

Addresses ~140 Coverity "Variable copied when it could be moved"
defects across 74 files.  Every std::move() targets a local variable
whose value is consumed by push_back, emplace, assignment, lambda
capture, or a function call and is never read again afterward.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* clang: use std::make_shared

* clang: use std::make_unique

* address feedback

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-07 14:40:38 +09:00
Goober5000 2b6e20360d assign sip->model_num from inside model_load, plus a few tweaks 2026-05-05 00:19:47 -04:00
Goober5000 0642dcceab fix a few bugs in model loading
Each time `model_load` is called with a `ship_info` pointer, which causes it to load subsystems, the model number MUST be assigned to the ship_info.
2026-05-05 00:19:47 -04:00
Goober5000andClaude Sonnet 4.6 6e5e342575 fix asteroid field undefined behavior
Three out-of-bounds/UB fixes for issue #6793:

- asteroid_create_all: skip field_debris_type[idx] == -1 entries when
  building the DG_DEBRIS odds table and loading models; iterate only
  over valid table slots during spawn. Matches the guard already present
  in asteroid_frame.
- missionparse: bounds-check subtype before indexing colors[] in the
  obsolete +Field Debris Type: parsing path.
- verify_asteroid_list: guard the asteroid_list[0] fallback access
  against an empty list.
- asteroid_init: emit an mprintf when no asteroids are defined instead
  of returning silently.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-04-30 02:10:49 -04:00
Mike Nelson 09029030c2 Qtfred unify flag lists (#7384)
* convert wing flags to the flags widget

* set tooltips on flags using flag descriptions

* add missing descriptions

* clang
2026-04-20 07:52:24 -04:00
Mike Nelson b1cefade1a Qtfred cargo title and scanning fields (#7387)
* implement newer cargo fields and clarify subsystem cargo settings

* static
2026-04-20 07:52:16 -04:00
Mike Nelson 4084c75678 Qtfred Dockable object list (#7368)
* qtfred dockable objects list

* fix jumpnode rendering

* more ouline panel features

* fix for wings

* remember list expansions

* clean up wing selection and layer handling

* disable top and bottom docking

* give scene outliner some padding

* replace old selection dialog with the scene browser

* fix some minor issues

* right click for wings and waypoint paths

* clang

* clang again

* fix status bar message

* 25 1 checks

* clang

* more clang

* address feedback
2026-04-15 23:07:01 -04:00
Mike Nelson 41a8b18fad Qtfred visibility layers (#7314)
* add visibility layers

* save/load object layers using the mission file

* use fill

* fix rebase error
2026-04-04 09:11:55 -04:00
Mike Nelson 54f0b410e7 Qtfred waypoint features (#7328)
* waypoint drawing features

* use ints

* parse and save as ints
2026-04-03 08:02:06 -04:00
Goober5000andClaude Opus 4.6 fa86575606 Suppress Coverity GLOBAL_INIT_ORDER false positives for safe globals
Add coverity[GLOBAL_INIT_ORDER] annotations to ~50 global variables
across 27 files. These were all analyzed and confirmed safe:

- ~48 OptionBuilder::finish() globals use a Meyers singleton
  (OptionsManager::instance()), which guarantees safe init order.
  Destruction is also safe due to shared_ptr ref-counting.
- 6 default-constructed container globals (vectors, maps) have no
  cross-TU dependencies at construction or destruction time.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-03-22 15:00:25 -04:00
Goober5000 6a20c0f549 Merge pull request #7117 from Goober5000/anchor_refactor
refactor ship anchors
2026-03-22 02:59:47 -04:00
Mike Nelson f01eec903a check, assert, and skip as needed (#7297) 2026-03-19 07:45:54 -04:00
Goober5000 fc48fac60e miscellaneous fixes
1. When loading and saving lighting profiles, treat an empty string as equivalent to the default name
2. Remove unused fields from the mission struct
3. Properly guard union initialization in `add_message`
2026-03-15 03:25:38 -04:00
Goober5000 ce31a33029 fix persistent variables and containers (#7192) 2026-03-13 08:16:28 -04:00
Goober5000 35ed88c57f make anchors type-safe, and adjust support_ship_info accordingly 2026-03-06 22:00:32 -05:00
Goober5000 33d5f7ed3c refactor ship anchors
Testing in FotG exposed a bug that dates back to retail.  During mission parsing, arrival and departure anchors were represented by indexes into `Parse_names`.  After parsing, they were converted to ship indexes -- but only in FRED.  Since some functions are shared between FRED and FS2, this can produce inconsistent results, which can be hard to detect since parse indexes and ship indexes are usually the same.

This refactors arrival and departure anchors to be represented by ship registry indexes in all cases.  It also adds conversion functions for the benefit of FRED and QtFRED since those dialogs were designed with ship indexes in mind.
2026-03-06 22:00:32 -05:00
Goober5000 1869b00af4 Merge pull request #7242 from Goober5000/props_missionsave
mission save compatibility
2026-03-02 21:53:44 -05:00
Goober5000 e39a900223 Merge pull request #7241 from Goober5000/fred2_fixes
fix a FRED2 crash
2026-02-28 19:46:11 -05:00
Goober5000 849acf200e show and hide cargo variants of cannot-perform-scan
The existing `cannot-perform-scan` flag prevents the cargo from being shown on the HUD, but some modders would like to see the cargo while still preventing a ship from being able to perform a scan.  So, this renames the existing flag to `cannot-perform-scan-hide-cargo` and adds a new `cannot-perform-scan-show-cargo` flag.  Compatibility code in both mission parsing and flag evaluation ensures that missions using the old flag will still work.

Note that if both `cannot-perform-scan-hide-cargo` and `cannot-perform-scan-show-cargo` are set, the former will take precedence.
2026-02-23 22:03:22 -05:00
Goober5000 418af70ea3 some ship utility enhancements
Add a useful function for getting a ship_info pointer from a ship registry entry.  Also rename `ship_has_dock_bay` to `ship_has_hangar_bay` for clarity, since docking bays and docking points are not the same thing.  Finally, add a `model_has_hangar_bay` function.
2026-02-20 23:11:07 -05:00
Goober5000 0666749ab6 mission save compatibility
Make sure that missions without props will still be compatible with earlier mission file formats.  If props are included, bump the mission file version.  Also, fix some newline behavior in the save code.
2026-02-19 09:54:26 -05:00
Goober5000 1832fa0397 fix a FRED2 crash
Fix a crash caused in part by some missing UI calls in FRED2 and in part by subtle object life cycle issues.  Depending on whether FRED receives the focus during mission load (which can happen if the autosave dialog appears) it could access props that were in the process of being cleaned up but were still referenced.  This isn't specifically a props issue; it could happen to any FSO object stored in a SCP_vector, since the vector can be cleared.

The quick mission init is to prevent a whole bunch of unnecessary and risky processing during a transient loading state, but it has the nice side effect of making mission list loading noticeably faster.
2026-02-19 00:29:53 -05:00
Mike NelsonandAsteroth 070a8e18fa Adds Props as a new object type (#6836)
* First draft of prop object type

* Add prop editor dialog in FRED

* prop sexps

* lua table prop support

* lab support

* lua mission access to props

* prop collision support

* use std::optional so the object->instance id is always valid

* allow props to block suns

* minor cleanup and remove arbitrary limit. Still limited to 500 objects.

* Sort props by category

* cleanup

* implement collision hooks

* parse prop flags and further ensure props are inited and closed correctly

* Add Cyborg's multi suggestions

* fix missing header

* add props to empty slots if available

* add multi signature

* fix rebase issues and match collisions to the new multithread style

* appease Clang the Conquerer

* save/parse mission prop classes by name

* Clean up comments and finish TODOs

* fix string errors

* clang wants this to be static now

* address feedback

* address feedback

* Use model num from prop info instead

* merge prop and ship collision group sexps together

* fix rebase bug

* address feedback

* fix name shadowing

* ship heavy submodel

* clang

---------

Co-authored-by: Asteroth <[email protected]>
2026-02-16 14:41:34 +01:00
Goober5000 fff480e101 tweak ship_cleanup
The object and ship indexes held by the ship registry do not actually need to be cleared until `ship_cleanup` completes.  This will allow the ship to be referenced in any functions (via script hooks or otherwise) that are called during cleanup.

Tweak related script documentation while we're at it.

Follow-up to #7120.  Fixes #7122.
2025-11-21 02:32:20 -05:00
Goober5000 afcb4871a3 upgrade stuff_int_list with enum class types
For type safety, use enum class rather than int.

Also make a few miscellaneous tweaks such as adding a new casting macro and making detail level settings a bit cleaner.
2025-10-01 21:47:01 -04:00
Goober5000 e3ff08ea46 for docked wings, initialize some data before the wing is created
Docked wings are created with a sort of reverse-bootstrapped initialization sequence, since normally wings are created first and the wing creates the ships.  Issue #7041 found a hole in this sequence, as the mission log entry was added before the IFF was assigned.  Fix this bug, and potential future bugs, by moving the assignment of certain fields to immediately before the docked wing is brought in.  AI can't be moved that easily, so fix AI setup by calling a separate function.

Fixes #7041.
2025-09-24 23:47:14 -04:00
Goober5000 c1444781e8 check missions for missing hangar bays
It's possible for ships to be designated as arrival or departure anchors when these ships do not actually have hangar bays.  This cannot normally happen in the interface but can happen when missions are edited in a text editor, or are imported, or the modpack is changed.  So add warnings and checks for this situation.
2025-09-22 00:37:38 -04:00
Goober5000 300cd8a1cf Merge pull request #7049 from Goober5000/fix_anchor_error_handling
fix handling of invalid arrival/departure anchors
2025-09-21 15:36:07 -04:00
Goober5000 60b8876eb0 fix handling of invalid arrival/departure anchors
Missions with invalid anchors would previously cause crashes, so update the anchor code to fail gracefully:
1. Negative anchors (especially -1) could trip up the bitwise-AND in the mission saving code, so check for negative anchors *before* checking the special-anchor flag
2. In the event a mission runs with a negative anchor (which shouldn't happen because even `<error>` is added as a recognized anchor), handle the situation with if()s as well as Asserts
2025-09-20 23:59:34 -04:00
The Force db4f9e4370 QTFred: Ship Editor Modernization 2 Part 2 (#7026)
* Switch to using signals/slots rather than connect

* Adds coloured persona box

Adds coloured persona box/ fixes persona loading, and reduces amount of data reset on model change

* Update To new flags widget

Updates To new flags widget this reqires moving several non flag items to other dialogs, which also lead to adding a new feature that lets a custom guardian threshold be set in editor

* Switch to size_t

* Make Mission Spec work with changes to Flaglist

* Remove Duplicate member

* Clang Appeasement

* Make static

* Properly initialise guardian threshold

* Convert Player Orders dialog to Checklist box

Unfortunately also formats Shipeditordialogmodel

* Update Custom warp to modern style

* Update Initial status to modern style

* Missed a file

* Update Ship Flags Closing

* Remove QT Code from model

* Update Ship Goals Closing

* Update Special Stats Closing

* Minor Changes

* Replace Paths Dialog With generic checkbox dialog

* Update Texture Replace to modern style

* Cast to int

* Initialize then append

* Clang Fixes

* Two didn't save

* More Clang

* Tighten NOLINT's

* Remove dead code

* Change to built in buttons
2025-09-20 08:18:40 -04:00
Goober5000 bf51f8ee91 fix load/save mismatch in missions
When `$Contrail Speed Threshold:` and `+Volumetric Nebula:` are used in a mission, builds since 23.1 would throw an error, since the fields were loaded in a different order than they were saved.  It turned out that the save order was the correct order, so this fixes the load order.
2025-09-14 16:50:11 -04:00
The Force 1310c38642 QTFRED Ship editor Modernisation 2 Part 1 (#6989)
* Switch to using signals/slots rather than connect

* Adds coloured persona box

Adds coloured persona box/ fixes persona loading, and reduces amount of data reset on model change

* Update To new flags widget

Updates To new flags widget this reqires moving several non flag items to other dialogs, which also lead to adding a new feature that lets a custom guardian threshold be set in editor

* Switch to size_t

* Make Mission Spec work with changes to Flaglist

* Remove Duplicate member

* Clang Appeasement

* Make static
2025-08-27 12:38:43 -04:00
Mike Nelson bc083dc61b QtFRED Mission Specs Dialog (#6945)
* refactor mission specs dialog

* clang

* Stub in all the sub dialog files

* custom strings dialog

* custom strings dialog cleanup

* custom data dialog

* sound environment dialog

* move custom wing names into mission specs subfolder

* custom wings dialog

* unused

* clang tidy

* clean return

* refactor mission specs dialog

* move custom wing names into mission specs subfolder

* custom wings dialog

* rebase error

* remove a couple empty functions

* select after creating
2025-08-24 10:10:22 -04:00
Mike Nelson 7d8b437847 Qtfred Wing Editor Dialog (#6939)
* wing editor dialog base functionality

* flags and path masks plus some cleanup

* squad logo selection

* custom warp params using the ship editor version

* some cleanup

* some finalization

* cleanup, fixes, and clang

* remove duplicate lines after rebase

* merge namespaces
2025-08-23 10:57:54 -04:00
Taylor Richards 5fd06b40fe fix multi crash loading campaigns (#6871)
A minor bug in #6077 resulted in a crash loading campaigns on the multi ui.
The bug itself was not fatal, however it triggered a cascade of poor error
handling which led to a crash. A lot of these issues date back to retail.
This fixes the minor bug, and hopefully adds enough error handling to
preemptively squash a repeat of the crash problem.
2025-07-25 21:15:31 -04:00
wookieejedi 86622e1ce0 Fix Edge-case with $Preload briefing icon models: (#6850)
Found a very interesting edge case bug with `$Preload briefing icon models:.`

Situation: Mission 1 has a briefing which has a ship class A as the class (and thus loads the model), but the ship class A is not actually in that mission so no subsystems are loaded. Then in mission 2, the ship class A is actually in the mission but FSO tries to reuse the slot that was loaded, but realizes no subsystems were loaded and makes an error message. I that is because the preload code for the briefing icons on `missionparse.cpp` line 6664 just calls `model_load` but does not specify the subsystem argument.

 I've also attached a retail mod reproducible campaign (2 missions, first is 5 seconds long). When the second mission loads the incorrect subsystem warning appears.

This PR properly loads the subsystems and fixes the bug. Tested and works as expected.
2025-07-20 15:00:47 -04:00
Taylor Richards 552f9990d9 remove support for memory mapped files (#6748)
FSO doesn't appear to use this any longer. And even when it was enabled the
requirements made it largely useless anyway. Removing to clean up cfile a
bit and so we don't have to keep maintaining it.
2025-06-05 17:53:13 -04:00
Goober5000 d7796b3767 coverity: use references to avoid unnecessary copies 2025-05-10 01:15:46 -04:00
Goober5000 60b676cba9 change Player_use_ai from int to bool 2025-04-06 02:11:52 -04:00
Goober5000 a5308d67d3 handle starting shipname mismatch
If the player starting ship name does not refer to an actual ship, gracefully fail to load the mission instead of crashing.
2025-03-26 01:11:51 -04:00
Goober5000 44cdb29135 some refinement of shield quadrants
Remove the `n_quadrants` field because it is entirely redundant to the size of `shield_quadrant`.  Also, be more rigorous about the difference between `shield_get_quad(i)` (which can fluctuate) and `shield_quadrant[i]` (which gives the exact quadrant strength).  Finally add some C++ casts and move some checks to better places.
2025-03-08 01:10:59 -05:00
Goober5000 4797ce55a2 use vm_vector_2_matrix_norm on normalized vectors
Most places in the code that use `vm_vector_2_matrix` do so on already-normalized vectors.  Changing these to `vm_vector_2_matrix_norm` avoids redundant normalization.
2025-03-02 23:07:09 -05:00
Mike Nelson 103ad70587 Allow preloading briefing icons (#6548)
* allow preloading briefing icons

* nullptr

* oops

* Fix from rebase
2025-02-02 16:42:36 +01:00
BMagnu 5ce7881a27 Merge branch 'master' into particle_cleanup 2025-01-19 19:56:18 +09:00