Commit Graph
30 Commits
Author SHA1 Message Date
Goober5000andClaude Opus 4.8 bed228d264 avoid undefined behavior from UNREACHABLE on reachable code paths (#7555)
* avoid undefined behavior from UNREACHABLE on reachable code paths

UNREACHABLE expands to __assume(false) / __builtin_unreachable() in
release builds, which is undefined behavior if the code is ever actually
reached. Many UNREACHABLE sites only guard against unexpected-but-
possible runtime states (values from tables, mission/save files, network
packets, scripting, or user input), so reaching them should degrade
gracefully rather than invoke UB.

Replace UNREACHABLE with Assertion(false, ...) at all such sites. It
still pops an error in debug builds, but in release it is a harmless
no-op that simply falls through to the following code. Sites that are
genuinely unreachable by local invariants (e.g. a switch over a bounded
random number) are left as UNREACHABLE.

A few converted sites had no safe fall-through -- an uninitialized read,
null dereference, or null call would have followed -- so they also get a
minimal recovery: initialize the value, guard the dereference, return
early, or skip the offending item.

Where the converted site was a simple guard of the form
    if (x) { Assertion(false, ...); return; }
hoist the check onto the invariant instead:
    Assertion(!x, ...);
    if (x) { return; }
This states the expectation directly and shows the offending value in
the debug popup, while keeping the same graceful runtime degradation.

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

* addendum

After consultation with Lafiel, use UNREACHABLE in situations that are effectively impossible even if not provably impossible.  UNREACHABLE = "this shouldn't ever happen"; Assertion = "if this ever happens, it's a coding error".  Also fix a few other sites and change a couple to Warnings.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
2026-07-09 11:20:25 +09:00
Mike Nelson 2fcf1ba686 Lab camera snapping widget (#7400)
* camera control widget with snapping

* fresh brain, fresh tweaks

* clang
2026-05-30 05:46:43 +02:00
Mike Nelson bca2721791 lab orthographic projection (#7336) 2026-04-03 08:02:41 -04:00
Mike Nelson afc1db7563 Lab camera controls upgrade (#7219)
* Add lab panning controls and align to pof tools

* pan based on camera view coords not world coords

* reset view option

* change scrolling to use mouse wheel

* Better ui for controls reference

* clang
2026-03-29 08:04:03 -04:00
Goober5000 a47d34c739 assorted const fixes
1. Change `ai_profile_lookup` and `multi_xfer_lookup` to use `const char *`, since all the other lookup functions do
2. Remove several unneeded `const_cast`s, some of which are now made possible by the non-const `data()` overload in C++17
3. Change `campaign_link` to use `const char*`
4. Use better string management in `test::FSTestFixture::init_cmdline()`
2026-03-20 11:33:54 -04:00
Mike Nelson e05bf3c3c7 Make sure we actually set old_class when changing classes (#7221) 2026-02-19 08:17:53 -05:00
Mike Nelson 6ae95c663b fix edge cases for mission background loading in the lab (#7237) 2026-02-19 08:16: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
Mike Nelson c51c5a3b0c don't assert for scripted animations (#7209) 2026-02-10 12:18:14 -05:00
Mike Nelson 634eece877 make this check less stringent (#7182) 2026-01-15 23:13:43 -05:00
Mike Nelson 966ac4d878 Allow testing bay paths in the lab (#6902)
* allow testing bay paths in the lab

* unused param

* static member methods
2025-08-13 08:36:53 -04:00
Mike Nelson 3f0c33046c unused params 2025-08-04 15:17:28 -05:00
Mike Nelson 1c482d76df default case 2025-08-04 14:55:11 -05:00
Mike Nelson e5a5c30fbf misc lab fixes 2025-08-04 14:24:03 -05:00
Mike Nelson e52fa1edeb No need to display debris label on objects in the Debris list (#6877)
* No need to display debris label on objects in the Debris list

* remove the unnecessary loop
2025-07-30 14:04:04 -04:00
Mike Nelson 4ad015881d Lab dock tester (#6715)
* Add docking and undocking test to the Lab

* address feedback
2025-06-12 14:46:20 -04:00
Mike Nelson 8410ed0249 Lab asteroid viewer (#6710)
* Allow viewing asteroid and debris objects in the Lab

* Address feedback

* Minor UI string tweak
2025-06-08 14:37:12 -04:00
Mike Nelson 5078826340 Lab Weapon Viewer (#6704)
* Activate Lab Weapon viewer

* Allow displaying weapon tech models

* check for a valid tech model when switching

* enable render options for weapons and tech models

* Some cleanup

* Clang

* address feedback
2025-05-26 07:40:08 -04:00
Mike Nelson 36d6fbe7e5 Lab firing upgrades (#6703)
* Fix some issues preventing various secondary types from firing in the lab

* Add ability to fire turrets from the lab

* const char*, mjn please

* more cleanup

* range-based for loop

* Update comment
2025-05-01 09:50:27 -04:00
Goober5000 e90416e199 Several coverity fixes (#6232)
* coverity - using `std::move` instead of copying, and change some parameters from value to reference

* coverity - fix or mark potential copy-paste mistakes

* coverity - various checking of parameter and return values

* coverity - miscellaneous fixes, and change some 'intentional' markers to 'false positive' markers
2024-07-06 12:51:31 +02:00
JohnAFernandez cfe92a4d32 Fix auto copies (#5738)
* fix inefficient (auto x : container) loops

* Don't make two copies of every element...

* Fix more loops

* Last inefficient auto loops
2023-10-31 13:47:48 -04:00
Goober5000 ab5e016dbb some updates to the lighting profile code
1. Add const qualifier where appropriate to API methods
2. Change `TonemapperAlgorithm` from enum to enum class, for type safety and token scope
3. Update saving of lighting profile in FRED
4. Add saving of lighting profile in qtFRED
5. Add lighting profile (and asteroid) initialization to qtFRED
2023-06-04 16:09:51 -04:00
ETP 7beb28b4f6 added lab interface for selecting lighting profiles. 2023-05-13 21:12:59 -04:00
EatThePath 89ffbb5a34 Merge pull request #5347 from EatThePath/ltp/profile-code-reorg
lighting profile code reorg
2023-05-13 21:11:58 -04:00
BMagnu 6e561761d1 Cleanup Variable Names for Volumetrics (#5362)
* Rename opacityDistance

* Add oversight
2023-04-23 08:16:12 -04:00
ETP 57f9455f6c moving lighting profiles into a namespace and arranging it as cleanup for future changes 2023-04-17 14:36:41 -05:00
BMagnu 7827cb4835 Add Noise intnsity lab integration 2023-03-02 13:01:10 +01:00
BMagnu 14b37add71 ImGui integration for neb settings 2023-02-27 16:49:39 +01:00
MjnMixael 5ba4e50685 remove ignored missions from the lab list (#5081) 2023-01-05 10:06:28 +01:00
Fabian WoltermannandFabian Woltermann 87926995df Feature/dear imgui (#4987)
* Add imgui

* migrate render options

* remove wmcgui

* Add subsystem selection and highlighting

* Add a syntactic sugar extension for imgui

* don't rebuild the mission list every frame

* Add imgui_sugar extension

* Move helper functions out of lab_ui, add function to display consolidated table text for object

* add button to export cubemap

* fix entering and exiting the lab

* refactor some of this for greater cleanness

* use techroom lighting when no mission background is set

* minor things

* add imguizmo

* add imguizmo

* Add imgui

* migrate render options

* remove wmcgui

* Add subsystem selection and highlighting

* Add a syntactic sugar extension for imgui

* don't rebuild the mission list every frame

* Move helper functions out of lab_ui, add function to display consolidated table text for object

* add button to export cubemap

* fix entering and exiting the lab

* refactor some of this for greater cleanness

* minor things

* add imguizmo

* add imguizmo

* Add button to reset changes made in the render dialog

* refactoring

* unfuck rebase

* fix issue with loose mission files

* use with_CollapsingHeader for greater uniformity

* add weapon selection functionality

* make primaries and secondaries fire again

* implement animation triggers

* avoid crash when switching back and forth between ships with and without team colors

* add control to set team color setting to renderer texture dialog

* make sure the table text updates when the ship class changes

* let rotating subsystems rotate

* do not add imgui.h to pstypes

* code cleanup

* add subsys highlighter from fred

* Highlight non-modelled subsystems as well

* add cmdline flag to show the imgui demo dialogue

* fix compiler warnings reported by CI

* fix error when building the subsystem list

* refactor variable/method naming

* code cleanup

* remove vestigial code

* update to imgui 1.89.1

* add credits entry for imgui

* use the imgui namespace

* Separate the background dialog out into its own window

* make sure the subsystem highlights are placed correctly

Co-authored-by: Fabian Woltermann <[email protected]>
2022-12-18 16:29:20 +01:00