Commit Graph
235 Commits
Author SHA1 Message Date
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 8d7a56c3a8 add Zero_radius_explosions_skip_fireballs
Addresses a behavior idiosyncrasy encountered by Solaris.  If this flag is enabled, explosions with a visual radius of 0 do not have fireballs created, and do not have the fireball lifetime added to the explosion lifetime.
2025-11-12 02:17:25 -05:00
wookieejedi 38acf9ae15 Allow mods to easily tune 'Target Hostile Bomb or Bomber' control (#7048)
* Allow mods to easily tune 'Target Hostile Bomb or Bomber' control

The `Target Hostile Bomb or Bomber` control targets bombs or bombers, though in mods may want a way to easily set exactly what this control does while still leveraging the utility of the 'bomb' flag for weapons and/or 'bomber' flag for ships (both of which affect AI behavior in various ways).

For example, in Solaris, Darius wants a way a way to allow players to only target bombs, while still allowing ships to be classified as as 'bomber'. In this case, the 'only bombs' option can be used. This PR adds a `$Behavior for pressing 'Target Hostile Bomb or Bomber' control:` to allow mods to set the behavior to `default` `only bombs` or `only bombers`.

For example, in FotG we want to allow players to target just bombers, as bombs themselves are hard to shoot down (critically though we still want the player to be able to manually target a bomb via 'target object in reticle'. This allows players to prioritize and easily target bombers while allowing skilled pilots to retain the option of manually shooting down bombs if they want an extra challenge. In this case the 'only bomber' option can be used.

Tested and works as expected in all cases.

* update using cleaned up function

* extra alt option for default case

* warning cleanup

* update default message

* whitespace clang

* appease clang with brackets
2025-10-15 16:47:45 -04:00
wookieejedi 7eff7900a6 Allow mods to tune generic debris generation (#7027)
* Allow 'No Impact Debris' to also apply to explosions

The ship/subsystem flag `no impact debris` prevents the default debris shards from spawning, which is very valuable especially now that impact effects can be completely customized via the -particles table. Now that particle effects are also an option for ship and subsystems explosions, it is also invaluable to have the ability to turn off the spawning of shards when either of those explosions happen.

This PR uses the same flag of `no impact debris` and simply does not spawn the default shards for ship explosions or subsystem explosions of that flag is enabled. I thought about adding two new flags, but that would add to the flag clutter, and most folks who use these flags to turn off impacts I would estimate also want them off for actual explosions. Also, a new flag called `no explosion debris` would likely be confusing, so if a new flag were to be added it should be called something like `no default explosion debris shards` or something. Overall I've opted with the simpler and cleaner solution to just have it all under the impact flags. If two new flags are desired though I can easily add them.

Tested and works as expected.

* throw clang a bone

* use two different flags

* update flag name

* typo and logic fix

* allow custom generic debris to always work

* update to better methods

* cleanup logic

* clang
2025-10-07 07:42:44 -04: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 3d8174d0d8 color/colour updates
Add Colour as a recognized parsing option in several more places where Color is used
2025-09-29 02:05:49 -04:00
Mike Nelson 1ffcaafc89 Allow customizing the fs2 selection effect (#6868)
* allow customizing the fs2 selection effect

* undo color color shift
2025-08-13 07:26:55 -04:00
wookieejedi f903180411 Fix/enhance skybox submodel rendering
Background:
Currently, skybox models can be set in FRED to have `No Z-Buffer` on or off. It is off by default, which is good because it ensures ships and other game objects cannot be rendered behind a skybox. Critically though, skybox models may have sub-models, especially now that animated sub-models are a feature (thanks to BMagnu!). If a skybox is using sub-models and `No Z-Buffer` is turned off, then there will be no proper model occlusion for the skybox and there will be ugly z fighting. Overall, BMangu stated "we could clear the depth buffer after the skybox with another flag".

Update
This PR fixes that issue by adding a new FRED game settings flag, `$Skybox internal depth consistency:` which when set to yes properly ensures there is internally consistency z-sorting with the skybox and any submodels it may have while at the same time ensuring that if `No Z-Buffer` is set in FRED that the skybox still correctly is always drawn behind mission objects like ships/debris.

Many thanks to @Bmagnu for the discussion and help in identifying and creating a proper fix for this issue that is clean, surgical, and supports all existing uses of `No Z-Buffer`.

Tested and works as expected. Fixes #6913.
2025-08-11 10:56:28 -04:00
wookieejedi 4ddcaec027 Debris Cleanup
In current master the debris creation logic was really showing some rust, which resulted in inconsistent behavior when using `Lifetime Min` and `Lifetime Max` for debris in the `ships.tbl`. Specifically, by default debris can randomly be set as `DoNotExpire` if the check `(Random::next() < (Random::MAX_VALUE / 6))` is false. This was set *before* the code that set the lifetimes from `Min` and `Max` from the table though, which could randomly result in debris with infinite lifetimes even if a min and max were specified (and the ship was small, since large ships trigger infinite debris by default always).

Also, by default, ships with a radius larger than 50 meters always had infinite debris lifetimes because of `MIN_RADIUS_FOR_PERSISTENT_DEBRIS`. Thus, this PR also allows modders to set that value in the game settings table.

Tested and works as expected.
2025-08-04 12:05:54 -04:00
wookieejedi 26e9ecab0e Allow mods to set threshold at which shield stops taking damage (#6847)
* Allow mods to set threshold at which shield stops taking damage

FSO logic dictates that shields collisions and any related sound or visuals related to shields are skipped if the shields are under 10%. This is rather unintuitive especially for mods, so this PR creates a game setting value that allows mods to set this value.

Also, this PR fixes a bug where the HUD shield gauge would try and incorporate this feature but did not do it correctly. Specifically, the gauge skips shield segment rendering if the raw shield strength was 0.1 not the percent. Incorrectly using the raw value results in HUD shields being rendered (albeit faintly) even if the damage was skipping the shield and directly damaging the hull. In other words, if the shield segment was 8%, the shield segment would show faintly even the shield is skipping damage.

Tested and works as expected. Also happy to discuss or answer any questions!

* update local variable name for clarity

* rename `ship_quadrant_shield_strength`

* cleanup with updated get percent function

* more cleanup

* wording and safety tuning

* use correct default number
2025-07-19 18:24:49 -04:00
BMagnu 650b8d4f07 Disable uneccesary raycast (#6811) 2025-07-08 11:05:11 +02:00
wookieejedi f1a25ab47d Per Request add flag for $Disabled or disrupted engines are silent: (#6792)
* Per Request add flag for `$Disabled engines are silent:`

Follow-up to #6781 as there are modders who use engine sound as ambient sound. Also cleans up the sound engine disabled logic.

* cleanup name

* update flag name
2025-06-25 07:50:46 -04:00
wookieejedi 54c00ce205 Two Sound Updates (#6781)
* Two Sound Updates

On current master, destroyed engines still make noise and the `Engine Minimum Volume` is not used by big ships. This PR makes two new game settings flags which allow mods to mitigate those issues (`$Unify minimum engine sound:` and `$Disabled engines are silent:`).

Tested and works as expected.

I also added both of these to the 25.0 default, but happy to alter however.

* disabled eng snd does not need flag fix

* ensure retail large ships still sound loud
2025-06-19 22:38:12 -04:00
wookieejedi 6e7128f26c Mod setting to disable shield effects (#6746)
Mods like FotG do not use the FS style shield hit effects, and simply disabling the shield rendering and checking is useful with one simple global variable.

Tested and works as expected.
2025-06-04 07:06:46 -04:00
wookieejedi 381f9fde58 Mod Specific Visual Culling Size for Lasers (#6729)
* Mod Specific Visual Culling Size for Lasers

Currently, lasers will not render if the length or both head and tail radii are < `0.0001`. This is very small, and in many mods the smallest visual size is `0.01`, so this PR exposes that culling size value to allow mods to optimize and tune visual culling of lasers, which can be quite useful especially in laser heavy missions.

* update names

* actually push all files
2025-05-21 17:56:55 -04:00
wookieejedi 8102febb08 Extra Visual Indication for Scramble Missions (#6720)
* Extra Visual Indication for `Scramble` Missions

Currently, if a mission is set as scramble then there is no visual way for the player to see that the Ship Selection and Weapon Loadout screens are locked, instead the player has to click on the buttons and hear the fail sounds or assess that the hover states are not triggering. This PR adds a text line right below the words Weapons Loadout that states "Ships/Weapons Locked" (XSTR 749) if the mission is scramble thus the player can easily see this right away and not have to check the buttons on every mission.

Tested and works as expected. Happy to put behind a flag if desired.

* whitespace

* incorporate feedback
2025-05-15 07:42:54 -04:00
Goober5000 42a973acf9 add flag to control model eyepoint normal usage
PR #6598 caused eyepoint normals to be used for viewing direction, whereas previously the host object's orientation was used for viewing direction.  Since this could cause compatibility issues, return to the previous behavior and make the new behavior depend on a flag that is set in post-25.0 builds.  (This only applies to eyepoint normals; eyepoint *positions* were respected both before and after #6598).
2025-04-19 02:01:20 -04:00
Mike Nelson f9d91d568e Add disable intro movie flag (#6688) 2025-04-17 08:21:49 -04:00
wookieejedi eb60a87b28 Allow mods to hide main Rearm/Repair items in Message Gauge (#6684)
* Allow mods to hide main Rearm/Repair items in Message Gauge

Adds a game_settings option to hide/disable the Rearm/Repair commands in the Squad Message Gauge. FotG does not use repair ships, so it is somewhat confusing to players to always see the `Rearm/Repair` order options (IE 5. Rearm/Repair Subsys and 6. Abort Rearm) and never be able to use them.

I wanted to make this PR as surgical as possible, while still giving some degree of generality, thus I went with the solution to use `active` as a true integer instead of simply an old int in the bool style. Now -1 is hidden, 0 is greyed out, and 1 is bright.

Tested and works as expected.

* update comment

* update with better name

* add another clarifying comment
2025-04-14 07:22:10 -04:00
wookieejedi eaebcf8ee6 Fix asteroids spawning outside active fields (#6615)
* Fix asteroids spawning outside active fields

Found an interesting edge case bug with active asteroid fields that has been present since retail:  if a large ship is just outside an active asteroid field, that field will end up spawning asteroids outside the field bounds. This is because the game thinks that the large ship is within the asteroid field when it is actually not. Specifically, the check `asteroid_is_ship_inside_field` does not properly account for the ship the addition of the ship's diameter to the bounding box check.

This PR adds a flag to fix that bounding box check and fix the bug of spawing asteroids outside the asteroid field bounds. Note, `asteroid_is_ship_inside_field` is used twice in the code, once within `set_asteroid_throw_objnum` and once following that call within `maybe_throw_asteroid`. Also note, `asteroid_in_inner_bound` uses a delta of 0 in all cases except when being called within `asteroid_is_ship_inside_field`.

Tested and this fixes the bug while still having asteroid fields work as expected. (Also took this chance to rename a local variable for newly create asteroids to more descriptive name).

* enable by default for 25.0
2025-03-07 08:19:21 -05:00
LuytenKy 3c907f2607 Add eyepoint flag for set-camera-host
Original issue post #6509. This flag controls if set-camera-host sexp uses the model's eyepoint for the camera position and orientation when no submodel is specified.
Without the flag, the camera will use the model's origin position and orientation.
2025-03-01 08:45:43 +02:00
wookieejedi 5392131a09 Option to unify setting options with easy flag (#6595)
* Option to unify setting options with easy flag

Most modern UIs, including KNet 1.3, have options that are always set and do not require the user to click save, or on the few cases where options will not be saved automatically, the program shows a popup telling the user the changes are not saved. In addition, the user experience of setting many options then forgetting to press save is far more common and annoying then the opposite. As a last example, even the F3 in-game options menu presents Escape as the leave and save button, not the leave and discard button.

Currently, there are two screens where FSO allows users to press escape after setting options and leave without warning. The main options screen and the HUD screen. As it turns out, half of the options in the main options screen get saved even if the player presses escape (all the detail slider options along with the joystick and mouse sensitivity and dead zone settings), so current behavior is inconsistent to users.

This PR, aimed to be strategic and efficient, creates a game settings table option that allows mods to set so that the escape key for the HUD and Options screen does the same thing as pressing Ctrl-Enter/Accept. This optional setting unifies behavior, so that setting an option sets it whenever the user leaves that screen (whether it is pressing Escape, Ctrl-Enter, or the Accept button). The other screen that involves options and an escape is the control config menu, but that already methods in place to deal with escape in a consistent way.

Tested and everything works as expected.

* fix oversight of saving when going to F3 menu

* update to enum for future additions

* cleanup with better naming

* update warning message

* one more warning cleanup
2025-02-20 08:35:24 -05:00
wookieejedi 1342f17a2d Allow mods to Always Show Directive Value Count (#6584)
* Allow mods to Always Show Directive Value Count

Previously, directive counts were not shown if the value was <= 1.
This PR adds a flag to always show the value, and tests work as expected. It also fullfills a longstanding statement from Mage

```
given that, aside from directive-value, all the code involving Directive_count seems to be volition:-original, it really is past time for a flag skipping this > 1 check
```

* cleanup
2025-02-09 13:45:37 -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
wookieejedi 7a07c995ca Add Mod Option to Limit 'Show Ship' when Toggling Cockpits (#6513)
* Add Mod Option to Limit 'Show Ship' when Toggling Cockpits

FotG uses cockpits and 'show ship', and also provides a way for players to toggle off cockpits. Unfortunately, if the player disables cockpits, 'show ship' still appears and looks very odd (since it appears the player is flying a ship with a hole in the center where the cockpit would be). Other mods have made entire ships with their cockpits, but FotG needs to use 'show ship' to match team colors and moving external ship animations.

This PR adds a game_settings option that allows mods to set to only use 'show ship' if cockpits are enabled.

Tested and works as expected.

* simplify logic

* fix typo
2025-01-13 19:30:30 +00:00
Mike Nelson 4dfaa85b6f Default settings tbl (#6491)
* initial version of default_settings.tbl

* Add a way to change player detail level defaults and implement a couple more options to detail_settings.tbl

* support the rest of 2d.cpp options

* Allow enforcing options to a specific value

* modernize detail defaults, levels, and values

* Fix parsing issue and remove lambda capture by reference

* fix print

* clang

* More efficient +Enforce parsing

* cleanup

* typo

* don't negate this

* error_display

* clarify language between presets, levels, and values

* add default case

* small fix

* use a map to minimize string lookups
2025-01-12 11:29:11 -05:00
Daft Mugi 642ff82833 Add FSO_BUILD_WITH_DISCORD cmake option 2024-12-21 22:50:51 -06:00
Mike Nelson 0a312263cb Allow defining custom overhead line colors (#6341)
* Allow defining custom overhead line colors

* Update asserts
2024-11-27 18:50:47 +09:00
Mike Nelson 4432341694 Scanning is chaos, let's make it sane (#6000)
* Unify scanning behavior

* Allow modifying the cargo title

* update localization

* update documentation

* update localization

* address feedback

* fix conflict merge resolution error

* fix oversights, missed subsys title # feature, additional xstrs

* don't need sprintf here
2024-06-08 22:20:22 +02:00
Goober5000 6edaea6056 Merge pull request #6122 from Dark-Visor/color_and_colour
Accept "color" and "colour" in game_settings.tbl
2024-05-07 01:12:43 -04:00
Goober5000 d1d173b99f Merge pull request #6116 from Dark-Visor/subtitles
Update Settings for movie subtitles #6064
2024-05-03 11:01:40 -04:00
Dark-Visor b7f4ad9780 Accept "color" and "colour" in game_settings.tbl
Allow optional strings in game_settings.tbl to recognise both
spellings - color/colour.
2024-05-02 13:57:16 +01:00
Dark-Visor 89e8961984 Add allowances for no alpha and spelling colour
User should be able to input 3 values (r,g,b) and let alpha default to
opaque. Also add "$Movie subtitle colour:" for English spelling of
color.
2024-05-01 15:23:06 +01:00
Asteroth f40941304c Account for scripting when dealing with velocity (#6110)
* add scripted velocity

* fix

* rejigger to handle displacement as well, and add flag

* review tweaks

* one more fix
2024-04-29 01:40:26 -04:00
Dark-Visor eb9c58dc2d Update Settings for movie subtitles #6064
Update mod_table and movie files to include settings for the color and
transparency of the subtitles.
2024-04-28 22:36:07 +01:00
Goober5000 148efb4713 add flag to not show callsigns in escort list
As a follow-up to #5523, some mods use callsigns for their ships but prefer not to display the callsigns in the escort list.  In lieu of a more flexible way to configure escort lists, a simple flag is sufficient to implement the desired behavior.
2024-04-18 13:46:58 -04:00
Goober5000 e3447223eb allow game_settings options to be read in any order
The ai_profiles.tbl options can already be read in any order, so it is modder-friendly to extend this capability to game_settings.tbl as well.  This also updates the "unrecognized parameter" log statement to indicate the filename.

Note that this commit should be viewed while ignoring whitespace changes.
2024-03-30 19:37:29 -04:00
wookieejedi 218a98dde3 Merge pull request #5978 from BMagnu/shader_backwards_compat
Add runtime flag to split up the main render shader
2024-03-29 23:14:36 -04:00
Goober5000 2626e7862b allow invalid arguments to be nil
A design choice very early in FSO's scripting development established that invalid results return invalid objects.  By using a game_settings.tbl flag, this allows invalid results to return nil instead.
2024-03-03 11:47:28 -05:00
Goober5000 bb9c76103b Merge pull request #5997 from ferralverrall/user/joverral/subsystem_under_reticule
allow targeting subsystems on already targeted ship under reticule
2024-03-01 15:33:12 -05:00
Mike Nelson 9c521d04d8 Retail ingame options (#5895)
* Create the ingame options game state

* Base working version of in-game options

* Cleanup + Optimization

* Localization pass

* more cleanup + documentation

* tooltips on option hover

* documentation and better inbounds check

* match case

* format strings instead of direct strings

* unused parameter

* address feedback

* localization id conflict with master

* Add this line back in

* pass the new option flags as well

* resolve xstr id conflict
2024-02-27 13:09:34 -05:00
joverral e4acd15a1e fix the string too! 2024-02-21 16:48:53 -08:00
joverral d16f46fb1c name change per feedback 2024-02-21 16:42:30 -08:00
joverral 77ad3ba0aa Fixes per feedback 2024-02-21 10:25:52 -08:00
joverral 25d326567e allow targeting subsystems on already targeted ship under reticule 2024-02-20 18:07:13 -08:00
Birk Magnussen da352c3eea Refactor gr_capability 2024-02-05 19:22:32 +01:00
mjn-mixael fb0a62c400 fix discord option needing restart 2024-01-24 10:07:37 -06:00
JohnAFernandez 65677542cb Merge pull request #5869 from MjnMixael/disable_cmdline_overrides
Disable cmdline overrides
2023-12-11 11:50:22 -05:00
mjn-mixael b9938b854f commandline to disable using ingame options 2023-12-07 16:45:43 -06:00
mjn-mixael 9e719440c9 Change the discord option category to "game" 2023-12-07 10:31:15 -06:00