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.
We have debug commands for sexps, so here are a few for scripts. These will be very useful for script developers to perform diagnostics and troubleshooting.
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.
`clang-tidy` doesn't pass in the compilation flags normally provided by cmake,
so add the vulkan flags manually to make sure that everything is checked
as it should be, and thus prevent it from choosing the static dispatcher
and complaining about `.init()` being used.
Because these functions can return statuses that aren't strictly an
error (and thus don't raise an exception), but might have to be handled,
they return a `vk::Result` that's `[[nodiscard]]`. Ideally some of the
result statuses would be handled here, but to get it to compile, cast
the result to void.
In 133b033ea0, SCP_vector was made into a
subclass, so direct assignment from the vulkan-hpp result isn't possible
anymore. Use an intermediate vector.
* One fix and one enhancement to AI shield behavior
This PR adds one fix and one enhancement to AI shield behavior.
1) Fix: Testing, especially in FotG, revealed an edge-case bug with shield management where the AI will not direct shield energy to a quadrant if it was hit when that quadrant was down. In other words, if a shield quadrant is knocked down to 0 and continues to be shot the AI will not realize it needs to direct energy to that quadrant. This is because `quadrant` is set to -1 if a shield segment is down. This ensures that the resulting effects and damage calculations properly ignore that quadrant downstream, but it also results in `aip->last_hit_quadrant` being set to -1. This PR adds a fix to properly record which shield was actually hit, so that the AI knows to direct energy to that quadrant.
2) Enhancement: In combat situations with fire coming from many directions, it is good practice to keep shields equalized, so this PR adds a flag for the AI to always attempt to balance shields, even if it is being fired upon (instead of the current behavior to always direct energy to the hit shield quadrant).
Both flags are tested and work as expected.
* fix copy paste
* rename to avoid previous confusion
* also make as ai class flag
* Fix crash when clicking inside the hud area but not on a gauge
* add dogfight_variant weapon flag for sorting purposes
* fix weapon display for default hud and skip dogfight weapons on auto-select
* cleanup the mouse check function
* it's broken and i don't like it
* it's fixed and i approve
* add multi support maybe
* appease clang
* appease clang ii: electric boogaloo
* const refs
* increment multi version
Add `UINT64_T_ARG` and `INT64_T_ARG` macros for printf arguments, similar to `SIZE_T_ARG` and `PTRDIFF_T_ARG`.
In the process, fix some issues with the toolchain: in certain CI runs the toolchain headers were being #included multiple times, and certain CI runs produced collisions between clang definitions and gcc definitions. Resolve these issues with `#pragma once` and preprocessor guards in the event of both gcc and clang being active.
Also remove toolchain.h from sexp_container.cpp since it is already #included via pstypes.h.
* 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
* 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
* Few Minor Visual Indicator Enhancements to Loadout
This PR adds a few visual indicator tune-ups to the loadout screens.
1.
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.
2.
Currently there is a nice orange coloration of the player ship icon in the Ship Selection wing loadout. This immediately shows the player which ship is theirs, but this usefulness does not translate to the Weapon Loadout screen. The player must select another ship, besides the player ship, to have the player ship show up as orange.
This PR adds a bool `always_highlight_ply` which is specifically for the weapon `draw_wing_block` function when called as as part of the weapon loadout routine.
Both PRs are tested and work as expected. I currently have these PRs on without a flag, but if folks really do not want the PRs or would prefer them to be behind a flag, then I'm happy to do that, too.
* separate PRs
Two updates to the energy transfer system.
1. Previously, for fighters missing a system (e.g. shields), the energy would be treated as if all energy from that system was routed to the other systems. So, for example, a fighter's typical speed would be faster without shields than with shields. A new AI profile flag now treats the other systems as if the energy had not been transferred.
2. At some point in development, Volition intended the `$Power Output` ships.tbl field to affect ETS. A new AI profile flag now treats the power output as a factor of energy applied to energy systems.
1. Add an explicit `mn.createWaypointList` function
2. Allow `mn.createWaypoint` to be used with an empty waypoint list
3. Update documentation of `mn.createWaypoint` to clarify optional arguments
The `continue` statement in these error checks had no effect because the error checks are macros implemented in a `do` ... `while (false)` loop. So, use `goto`. There is precedent with other instances of `OpenAL_ErrorCheck` in the code.
This may fix the issue where sound would occasionally randomly stop, requiring a pause or a screen change to get it back. This would be difficult to verify though.
Thanks to Coverity for flagging this situation!
The Input of `Trigger Radius` for curves within new particle effects was never hooked up for muzzle flashes, so this PR adds in the necessary lines to get it working. This allows modders to make a muzzle effect that can scale to the weapon radius through curves, and thus modders can simply make one curve scaled muzzle flash and avoid making a many muzzle flashes for each sized weapon that uses the same base effect.
Tested and works as expected.
If a ship changes class, the dockpoints on the new model may not match the dockpoints on the old model. This is most likely to happen when changing a docked ship in FRED to an incompatible ship class, but it can also happen when using the `change-ship-class` SEXP. So check the dockpoints, update them if they should be updated, and undock them if they can't.
* Allow defining separate player and target shield icons for config
* rename define to prevent confusion with a similar define in shield.cpp
* address some feedback
* 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
Most of the functions in ship.cpp that operate on submodel animations are mirrored in animation_handle.cpp, but `setAnimationSpeed` was overlooked. Add this function so it can be called from a submodel animation handle.
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).
The `println` function is a semi-recent addition to zLoadFirst-sct.tbm, while the `Globals` table should have the vector and orientation values. The `string.starts` and `string.ends` functions were in the original version of zLoadFirst-sct.tbm but were not included in #6545, and `string.ends` is required by cfile_include.lua.
* Wingmen and Squad Message QoL Updates
This PR adds a few assorted HUD updates/quality of life enhancements. FotG will be using these, though they relatively general and are likely useful to most other mods, too.
1) Adds a 'Ship Name Max Width:' to the Squad Message Gauge (following the same logic as the Escort Gauge). The Escort Gauge will truncate display names of ships if they are too long, that way all the text fits in the gauge without spilling over. It would also be very useful to do this with the Squad Message Gauge, as long display names can overflow out of the gauge's boundaries currently.
2) Adds `Wingname Align Mode:` to the Wingmen Gauge, which allows modders to set how the wingnames are aligned. Currently they are centered on the calculated x-position, though this PR also adds right and left justification options (which is useful especially if displaying the full wing names).
All options are tested and work as expected.
* appease clang
* whitespace
* more safety and error checking
* and extra error helpfulness
* use safer str copy
Some QoL improvements:
1. Update `$fvec` and `$uvec` parsing to also allow parsing `$rvec` and to allow only `$fvec` to be specified; also make parsing more robust against failure
2. Allow `$fvec` and `$uvec` to specify the "facing" direction if `$look_at_offset` is not specified
3. Add a few additional warnings for incomplete or invalid POF data
* 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
Github runners for Linux arm64 are now in public beta with the same
free limits as normal github runners. Our Linux build images already
have arm64 support so this finally enables it as part of the official
workflow.
This was discovered thanks to the new assertions from #6596. For particles with 0 velocity, the code would attempt to normalize a 0,0,0 vector with predictably undesirable results. So, pick the global `z` vector in these cases, while normalizing in the usual case.
Linux iconv does not support "UCS-2-INTERNAL" and conversion will fail if SDL
is compiled with native iconv support. SDL version 2.32.2 fixed this by
changing the macro to use "UCS-2" instead. Unfortunately in my tests this
worked perfectly in Linux but was broken on Mac in the rocket_ui code. However
simply using proper endianess appears to work on all test platforms.
Additionally this fixes a bad memory leak as SDL_iconv_string() allocates it's
return string and this was never free'd before. So every character of text
input resulted in a memory leak of 6+ bytes.
Update haptic code with changes from icculus.org tree which optimizes
effect loading to better support low-memory devices and no longer
requires full support of every haptic effect type. Additionally...
- avoids attempting FF init for non-haptic devices
- avoids attempting FF init for gamepads
- properly resets FF when device is hot-plugged
- better start/stop/update of effects
- avoid stopping effects unless really needed
- use timestamp for dir effect restarts instead of sys calls
- avoid playing FF effects when window is in background
- general code cleanup
Return the current supernova stage. This sexp, in conjunction with mission cutscene editor, makes it possible to reproduce the FreeSpace 2 end-of-campaign cutscene behavior purely in FRED. The resulting cutscene section looks like this:
```
$Campaign End Cutscene: endpart1.mve
+formula: ( true )
$Campaign End Cutscene: endprt2a.mve
+formula: ( < ( get-supernova-stage ) 3 )
$Campaign End Cutscene: endprt2b.mve
+formula: ( >= ( get-supernova-stage ) 3 )
```
Also add a new status subcategory and fix newline behavior when saving the cutscene section.
Fixes#6657.
* lua access to the comm board menu
* On Order Issued Lua Hook
* Some cleanup and safety checks
* Add mn.sendBuiltinMessage and perform more cleanup
* Send the correct ship to the hook for Sender
* clang cleanup
* address feedback
* fix build errors introduced from upstream
* basic hook conditions
* properly link the condition and the oswpt struct
* some requested cleanup
* allow for sending custom built-in messages
* address more feedback
* more prefix
Previously, FSO did not show normal, AO, or misc maps at LODs 3 or higher. This was a relic from original retail days, so this PR allows players to see those textures if the model detail level is at 3 or 4. I put this under the model slider because it is related to LODs, and b/c changing the model slider is something folks actually use compared to the other hardware tex slider which really makes things look ancient if turned to anything other than the max.
In-game options may be removed/inaccessible, such as VR mode removing the Window, but still valid for listing in the `default_settings.tbl` table.
In other words, we don't want error messages displaying if a player is playing in VR mode (which will remove the Window option for that instance) but the window option is listed in the table.
Thus, downgrade the error to a debug print for options within the `default_settings.tbl`. As MJN stated, the table itself controls the parser here, so downgrading the warning is the best choice.
* Make VR mode more seamless
Works to make the `-vr` command flag more seamlessly work (which means the new KNet button, `Play in VR` will also now actually work). Fixes#6430.
First, creates a new in-game option called VR Resolution and have the default be 2500x2500, with a range that goes from 1000x1000 to 6000x6000.
Second, if `-vr` flag is used, then it auto sets flags of `-capture_mouse` `-stretch_menu` and `-window_res 1000x1000` (or anything that's for sure smaller than the screen but not too small, to maintain mouse precision).
It also overrides settings of `-vysnc` and `-window` to off, by ignoring the in-game values (and does not show these options in menu while in VR mode).
Finally, it reads the in-game value of `VR Resolution` instead of `Resolution`. It also shows the `VR Resolution` in-game option in the menu, while hiding the options of `Resolution`, `Windowed Mode` and `Vsync`.
If the game is run in standard mode then FSO does what it current does, including using the `Resolution` value for screen resolution. It also does not display the new in-game option for `VR Resolution`.
* actually use the vr_enumerator
* use emplace_back instead
* update res vr importance
* Fixes for VR one-button mode
* try reordering removes for clang
* fix string ids
* test to see if clang is being weird
* revert clang test
* strings index update
* cleanup options manager
---------
Co-authored-by: Birk Magnussen <[email protected]>
Ships that red-alerted, but that departed before red-alert was triggered, would have 0 weapons on the subsequent mission. Since exited ships do not store weapon information, that information was never saved in the red-alert status, and so `num_primary_banks` and `num_secondary_banks` would inadvertently be set to 0. This bug has been around since the pilotfile upgrade in 2013, and apparently was common knowledge among several players, but was never reported. :-/ The fix is easy enough: skip setting weapon information if that information is not saved in red-alert status. (We should also skip setting subsystem information in the same circumstances, although that did not cause any subsystem misbehavior.)
Although normalized vectors in FSO are supposed to stay normalized, occasionally small floating point errors can pop up. In most cases these do not cause a problem, but in certain cases these errors can rapidly accumulate and corrupt an otherwise well-behaved matrix. This can most easily be seen with daisy-chained dock sequences or docked ships with angled dockpoints.
This PR audits the usage of `vm_vector_2_matrix_norm` to re-normalize vectors in cases where floating point errors could accumulate. There are also a few new Assertions for extra vigilance.
Follow-up to #6596. Fixes#6634.
The official 1.2.1 release of humbletim/setup-vulkan-sdk was recently published. Update the repo version and, incidentally, also the vulkan version. See https://github.com/humbletim/setup-vulkan-sdk
Follow-up to #6582.
Improve skipmemymissionyo in several ways, based on RedMageJoe's recent experience:
1. Allow spaces to be accepted in the mission prompt
2. If the requested mission can't be found, just abort rather than restarting the entire campaign
3. Clarify that the prompt needs a filename and add a message if the mission can't be found
4. Improve handling of the .fs2 extension
5. Fix a bounds check in `popup_input`
* Fix/cleanup using `intrinsic no shields` and ship loadout switching
The flag `intrinsic no shields` is used to allow switching between both shielded and unshielded craft in loadout. There is one edge case that was not accounted for though, which is that if a ship has no shields, and is switched to a ship with shields, the mission will start with that ship having a current shield strength of 0 and only slow get it's shield strength up via shield recharge.
This is not expected behavior, so this PR adds the extra conditional check that if that flag is on, then treat shield percent as full instead of empty. This ensures that switching to a ship with shields in loadout will begin the mission with full shield strength (instead of 0 and waiting for a full recharge).
Tested and works as expected. If desired I can put this behind a game settings flag, but I figured this was the expected behavior (and I'm not even sure how many mods besides FotG uses `intrinsic no shields`.
* also fix initial ets setting with intrinsic no shields
* format consistency
Fixes a bug where the fire-point and flight cursor position components of the center reticle were improperly calculated. Also fixes bug where the fire-point component was missing an argument for `renderCircle`.
Tested and fixes work as expected.
* base working version
* localization and minor tweaks
* add retail UI controls
* Add way to hide gauges from Config view
* convert hud config from index matching to id matching
* clang
For every move and move-assignment constructor, do the following:
1. Make it default if possible
2. Add or delete where appropriate
3. Check for move-onto-self
4. Apply `std::move` where needed
Also fix problematic moves in `player_h`
Copy existing code from change-ship-alt-name into new sexp
change-ship-display-name and likewise from OP_SHIP_CHANGE_ALT_NAME to
new OP_SHIP_CHANGE_DISPLAY_NAME. Create new blank function
"sexp_ship_change_alt_name_or_callsign" and a function for multi too.
When an orientation matrix is constructed using one or more vectors, all such vectors must be normalized. Previously, the code did not enforce this for matrices parsed from a mission or table file. Although FRED will use correct matrices, it also truncates floating point values to six decimal places, so non-normalized vectors might be written to the mission file as happened in #6632. And there is always the possibility that someone could manually edit the mission file to corrupt the matrices.
While we're at it, per suggestions from Asteroth and qazwsxal, make sure the matrix is orthogonal as well. The `vm_fix_matrix` function handles all relevant calculations.
Fixes#6632. Follow-up to #6596.
Coverity hasn't run since September 27. A close look at the log shows that the workflow makes it almost all the way through but fails on the "Upload to Coverity" step:
`fatal: detected dubious ownership in repository at '/__w/fs2open.github.com/fs2open.github.com'`
There are various questionable ways that people have tried to fix this, but it might be possible to completely avoid the issue by not using `git` in that step. So let's try to get the commit hash from GitHub context rather than by running `git rev-parse HEAD`.
Currently if you try to set a subsystem's hit points via scripting it only sets the value to 0 b/c of what was likely a copy paste bug. This 1 line PR fixes that. Tested and fix works as expected.
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.
* 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
Use `std::unique_ptr` rather than `vm_malloc` and `vm_free` to handle optional strings in ship classes. This makes the code more robust and increases memory safety. This also allows several string variables to be consolidated in the ship class and weapon class script APIs.
Also add new `stuff_string()` overloads and a new `F_TRIMMED` string parsing type to handle the new fields and the string trimming done inside `stuff_malloc_string()`.
1. Use `const char *flag_desc` because constructing a SCP_string for each flag description is not needed
2. Make `VALID_FNAME` check for nullptr
3. Modify the signature of `coalesce()` to allow capturing of mixed `const` and non-`const` arguments
4. Use `std::for_each` (via `SCP_tolower`) rather than `std::transform` to fix compilation warnings
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.
Currently, the cursor does not revert correctly after visiting F3 options screen or lab due to IMGUI unsetting the FSO cursor image.
This PR reloads the FSO cursor image when those screens end. Fixes#6436.
Tested and works as expected.
Upgrade `parse_get_line` to detect all three EOL types: CR, LF, and CRLF. The function is now more robust against line ending mismatches and will now also warn the modder if a file contains mixed line endings.
Fixes#6395.
There were rather prominent strings shown for joysticks that were never localized. This PR localizes them to allow for proper translation support.
Tested and works as expected.
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.
1. Trim trailing whitespace on any property values, just as leading whitespace is trimmed. All places where `get_user_prop_value()` is used implicitly or explicitly require this.
2. Warn the user if an invalid `$special` value is parsed. This would have caught #1, and will now catch related errors, such as misspellings, in the future.
3. Enhance `string_lookup()` with the ability to print the list being searched, if desired. Remove an unused version of `string_lookup()`.
4. Check for lower-detail submodels being recognized as subsystems.
There were two rather prominent strings shown in popup windows related to the more modern control presets that were never localized. This PR localizes them to allow for proper translation support.
Tested and works as expected.
* Create scripting hook: 'On Options Menu Closed'
Complements #6591. This PR creates a hook, 'On Options Menu Closed' that provides a hook variable of `hv.OptionsAccepted` which is true if the options are accepted/saved, false if the options are discarded and not accepted/saved.
When searching to see if there is an extension mismatch for a soundtrack audio file, go ahead and substitute the mismatched extension if found. Matching extensions is important, so continue to display a Warning; but for the benefit of players and out-of-maintenance mods, it is more friendly to play the mismatched file even if the audio data is inaccurate.
1. Allow `ship_get_eye` to be used for any objects, not just ships
2. Remove the unused `from_origin` parameter and add `local_pos` and `local_orient` instead
3. Simplify the implementation and take advantage of upgrades to `model_instance_local_to_global_*` functions
4. Consolidate `ship_get_eye_local` into `ship_get_eye`
1. Refactor `num_hits` to `num_sparks` and `MAX_SHIP_HITS` to `MAX_SHIP_SPARKS` to be consistent with their current (since FS1 pre-release) usage.
2. Remove the unused `HP_SCALE`.
3. Always initialize at least one spark pair. If `choose_next_spark()` was entered when `num_sparks` was 1, `num_spark_pairs` would be 0 and none of the spark pairs would be initialized. Consequently, accessing the pair at index 0 would return garbage data.
4. Iterate through `num_spark_pairs` when counting the indexes, rather than the hardcoded (and incorrect) magic number 6.
Fixes a crash discovered by Dawnesya that can only occur when a ship has both the "fighter" and "cruiser" flags. Normally, fighters never enter the `choose_next_spark()` function and 'big' ships always have at least 3 sparks.
With the old style, `LBS_MULTIPLESEL`, clicking once allows the user to select/deselect a poof, and multiple selection/deselection is done by clicking multiple times. With the new style, `LBS_EXTENDEDSEL`, clicking once changes to a new single selection, but clicking and dragging, or clicking with Shift or Ctrl, creates or modifies a multiple selection. This should be a more user-friendly selection style for lists with large numbers of poofs.
* 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
* Make Cockpit Deferred an In-game Option
After testing and consideration, this PR adds the Cockpit Deferred setting to the in-game options. Also adds a parser to the new default_settings.tbl.
* cleanup comments
* Create scripting hook: 'On Options Menu Tab Changed'
It would be very useful to know which options tab is active (IE Options, Multi, Detail) but it's all under one single Game State `GS_STATE_OPTIONS_MENU`.
This PR creates a hook, 'On Options Menu Tab Changed' that returns the value of the newly switched to options tab. Lafiel and I both discussed making this an ENUM, but the ENUM list is already quite bloated and this integer value seems like the cleanest solution.
Tested and works as expected.
* fix description typo
* Unify AI Usage of Shield Manage Delay
`$AI Shield Manage Delay:` can be set in the AI profiles, but also set for AI specific classes. Currently, The values set for the specific AI class are only used `if (iff_x_attacks_y(Player_ship->team, Ships[objp->instance].team))`, otherwise the values in the AI profile are used.
Being able to have the shield delay work in a unified way according to the AI class values is very useful, especially for friendly wingmen that you want have different shield manage delays.
This PR adds a AI profiles flag to unify Shield Manage Delay behavior, so that it always works in the same way regardless of AI team conditions.
* cleanup unifying behavior along with CM firing chance
* restore what sushi had for now
* Allow modders to always show first game tip at start
This PR adds a simple boolean that allows mods the ability to always show the game tips in the same order, starting with the first entry. This is particularly useful if the mod is introducing something to new players.
The current behavior is to pick a random starting location, so this PR just always starts at tip index 0.
Tested and works as expected.
* add comment clarification
* make into integer instead of bool
* better tips index setting method
* spelling and static cast
* one more static cast
* make actual warning
* clang and consistent order
* 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
As discovered by PDFCommand and tracked down by Asteroth, there was another "missed target" check in `ship_weapon_check_collision()`, in addition to the more comprehensive check in `weapon_home()`. Since the check is redundant and there is an existing `$Fixed Missile Detonation:`, skip the check if the flag is active.
Allow `stringcost()` to use a specified function to check equality, and provide both case-sensitive and case-insensitive sample functions. Use case-insensitive checks for sexp operator lookup.
* Fix incorrect ship legacy particle curve assignment
* Setup trigger radius
* Properly attach particle sources to objects and subobjects
* Add trigger velocity for weapon impacts
* Onetime particle source timing fix
* Warnings
* Allow global_to_local to work with no submodel
* Allow global_to_local to work with no submodel, again
* Add scaling for vfnts and scale multipler to gr_string
* nullptr
* Add scaling to a couple other string operations
* Add scaling features to additional bitmap drawing methods
* Implement framework for rendering hud gauges in config mode
* fix merge error
* address feedback
Make `SCP_vector`, `SCP_list`, `SCP_set`, and `SCP_multiset` subclasses of their STL counterparts. This allows helper functions to be added to each, including the `contains()` function which is not available until C++20. (This has minor effects on other parts of the codebase that treated `SCP_` and `std::` as synonyms.) Since there is now a nontrivial amount of code that needs to be in a .cpp file, create vmallocator.cpp.
Note that `SCP_string` truncation has been refactored to use length rather than C-string size to be consistent with other `std::basic_string` functions.
Also, remove some enum class hashing code which is no longer necessary now that the codebase is at C++17.
Allow waypoint orders to target a specific waypoint and go in reverse. Add script access to waypoints and waypoint lists belonging to orders.
Fix assignment of targets and goal start times. Assign targets when they are different (and thus need to be assigned), not when they are the same.
* allow VFNTs to auto scale and disallow auto scaling in FRED
* fix shadowing
* Update FSFont.cpp
* don't code from your phone, mjn
* refactor to use one central method
Add "goal" as a type recognized by scripted sexps. Also add `mn.Goals` as a collection to complement `mn.Events` and move the goal type to goal.cpp and goal.h to match event.cpp and event.h. The new `mn.Goals` collection contains the same data as the existing `Objectives` collection in the briefing UI library, so the latter could be deprecated.
Several changes related to the volumetrics model fix:
1. Update the `model_load()` prototype with better parameter names, including a new `ErrorType` enum defined in pstypes.h
2. Update the `MIN`, `MAX`, and `CLAMP` macros, all of which were susceptible to performance issues because they duplicated their tokens. This could cause functions or calculations to be re-run unnecessarily. Since the codebase is now on C++17, `std::clamp()` can be used.
3. Update the rest of the codebase to fix any associated issues.
This type for subsystems is analogous to the shipname type for ships. Sometimes it is useful to refer to a subsystem even if its parent ship is not present. Whereas the subsystem object would be invalid, the subsystemname string still contains the string that the mission designer specified.
Relatedly, upgrade the parsing of `+Parent Parameter Index:` to be checked on both parented and non-parented parameters. This will help both modders who put the field in the wrong place and programmers who may want to add a parented parameter in the future.
This function call checked the acceleration of the targeted object, rather than the active object as it should have. Fix it to check the active object. For mods that use `$Random Sidethrust Percent:` (such as Inferno), this fixes a bug that could cause an invalid memory access in situations where the targeted object is -1.
Occasionally a link endpoint could be -1, such as with End of Campaign links, but there were no checks in the `add_link` and `remove_link` functions to protect against array accesses with a -1 index. Add checks in several places for this.
* Made lens flare size proportional to model size.
* Updated fireball_wormhole_intensity function to be smooth and unbreakable
* Added variable frame frate warp and new lens flare animation.
* Last animation changes made since I stopped coding.
* Made cinematic animation, warp-size ratio, and flare-size-ratio parameters configurable by table. New exp_to_line function to be more consistent and to fix a bug.
* Made everything configurable by table.
* Updated default values for cinematic warp animation.
* Fixed the usage of MAX() so that it assigns to the variable.
* Fixed obvious freakin' double to float casting warnings.
* Made requested changes. Flare animation can now be specified with an enum and default else statements will not override earlier entries.
* Changed warp table parameters to Warp flare style and Warp model style.
* Added defaults to switch statements, and made this backwards compatible with older mediavps.
* Removed commented code.
* Opened up flare flickering for table editing.
* Restored cinematic warp flare ratio default.
There were 2 popup dialogs that were missing an `Affirmative` flag, which mean the button was not in the right position and thus showed a visual misalignment. This PR fixes that and in tests works as expected.
`On Dialog Start` (used in SCPUI and within `popup_init`) reads popup options by affirmative or negative flags, and the popup for exiting the Mainhall did not set these flags. Notably, most popups that use `POPUP_NO` or `POPUP_YES` already, so this PR sets those flags for this popup. Now `On Dialog Start` within `popup_init` has access to the correct flags.
PR tested and works as expected, both in retail UI and SCPUI
Any NaN encountered in the evaluation of functional-if-then-else should be isolated to the branch on which it occurs. Fixes#6536.
Also improve some help text for clarity.
Looking through all places in the scripting API where `l_Object.Set()` is called, here is one where we might want to know about the object's breed.
(Normally we would return the result of `ade_set_object_with_breed()`, but the `testLineOfSight_internal()` function has multiple return arguments.)
The `query_modified()` function in FRED did not correctly check whether messages were modified, although interestingly, it did so in qtFRED. Even in qtFRED, there were a few minor omissions. Overall, this fixes FRED and syncs up the FRED and qtFRED versions.
Fixes#6528.
At some point between 2002 and 2006, the Update_window code was removed, but since we don't have FRED history from that period, we don't know the exact rationale. However, since FRED appears to have no difficulty rendering every frame, and since there may be parts of FRED that don't set Update_window when they need to (for example, the background editor), let's keep this disabled.
Follow-up to #6435. Fixes the background not updating when a bitmap is moved in the background editor.
Kamikaze ships entering broadside mode (`ai_cruiser_chase()`) would always point toward the center of the ship. With this fix, they will point toward a subsystem if attacking one. (In practice this situation had not been encountered before, since by default the ai-destroy-subsystem order is only available to fighters and bombers, which do not use broadside mode.)
Make these convenient functions even more convenient:
1. Change `object_get_model()` to `object_get_model_num()` and `object_get_model_instance()` to `object_get_model_instance_num()` to more accurately reflect what they do
2. Add new `object_get_model()` and `object_get_model_instance()` functions to return `polymodel*` and `polymodel_instance*` values.
* Fixes Debris not inheriting parent ship texture replacements
Debris chunks that use the same texture as the actual hull model are not updated when `texture-replace` methods are used. For example, a clean grey base textures that has texture replace via table or FRED is changed to red/brown. But when the ship is destroyed the debris objects are using the original lighter texture instead of the newer darker one.
#6154 provided the groundwork to fix this, but one step fell through the cracks; setting the debris hull textures to what the parent ship used.
This PR sets the debris texture replacements when debris is created to fix this (and fixes#2462).
Fix is tested and works as expected.
* cleanup setting shared
* get pmi correctly
Inferno reported a bug where the unavailability of weapon A could result in weapon B being assigned to a particular weapon bank, even if weapon B was disallowed for that bank. Add a per-bank restriction check to fix this.
* 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
This has been broken ever since commit 6c17ef09ab in 2005. Since `get_hull_pct()` did not return negative values, `percent_killed` was always 0. Allow negative values in this case.
There is a rather large design flaw in FreeSpace debriefings... debriefing SEXPs can refer to in-mission ship data, while all ships (and all objects) are deleted as soon as the mission completes. Specifically, `obj_delete()` is called which sets all objects to `OBJ_NONE` and marks them as freed, although the data still exists in the various arrays. This is the use-after-free problem, but applied to the in-game object system, rather than memory accessed by pointers.
It's probably best to defer fixes to an as-needed basis. As for hitpoint SEXPs, this change updates them to use the object and ship references from the ship registry, since the ship registry is not cleared by the time the debriefing is loaded. (Using `objp->instance` and `shipp->objnum` at this point would be problematic.) Since subsystems are also cleared at this point, this also updates the warning messages in those functions.
Fixes an Assert seen in debug mode in Inferno.
* 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
* Allow Modders to Tune Strafing
Many mods change ship velocities and damp values, but this commonly leads to poor behaviors attacking large ships within strafe mode (which is the main method for attacking big ships in a sustained way). As an example, FotG has damp and velocity values that are higher than base FS, thus the defined strafe values result in behavior where fighters never can complete a sustained firing pass against a large ship unless they are sitting and parking (which does not fit our goals to match the movie).
The values for dictating how strafe behavior occurs are easily editable by changing some key values, which this PR exposes to modders. Furthermore, mods may give large ships very long range weapons, so being able to set how far away a ship should do a strafe run begins is very valuable.
In testing it was very easy to get desired behavior of having AI do long sustained strafing runs. I estimate other mods will likely be able to leverage these values to tune strafing behavior.
I did numerous tests and evaluations finding the best balance of values to expose. I would be happy to discuss these changes in detail too, as I know this exposes a number of values.
* clang
* incorporate feedback
Now that `snd_do_frame()` has been tightened up to specifically only adjust audio for the adjust-audio-volume sexp, the redundancy-avoiding code in `snd_set_volume()` is obsolete. So, set the sound volume immediately, even if it is a looping sound.
This is a two-for-one fix; the proper setting of volume fixes both #6504 and #6507.
Change `currentlyLoopingSoundInfos` and `currentlyLooping3dSoundInfos` from lists to maps. The data structure should keep track of the volumes currently, as opposed to historically, associated with each sound handle.
Since the map requires `util::ID` and its derivatives to be hashable, add `util::ID_Hash`.
If the volumetrics model cannot be loaded, fail gracefully by warning and not generating volumetrics. This prevents a hard exit in the event of a model problem, particularly when a mission is being edited in FRED.
In the In-game options for `mouse_mode` the XSTR index for "Mouse" was set to 1774, which is already used for "Glide When Pressed". Luckily "Mouse" XSTR already exists with Index 1373, so this PR changes it to that.
The deprecation warning that required changes:
* CMP0054: Only interpret if() arguments as variables/keywords when unquoted.
The deprecation warnings that did NOT require changes as those
features were not used:
* CMP0026
* CMP0042
* CMP0045
* CMP0059
Follow-up to #6371 (and replaces #5960 since the goal of that PR was already taken care of with #6371 adding the procedural translation).
Overall tagging this as 25.0 since multiple folks have asking about bumping the limit
* Fixes Joystick Hat Labeling
Fixes mislabeling of joystick hat names that appeared in #6371. Tested and confirms this fixes the issue.
* fix ordering oversight
When a mission is loaded in FRED the "immobile" flag is migrated to "don't-change-position" and "don't-change-orientation". So, notify the FREDder that this is happening, and add checks to the "potential issues" checker to guard against mixing the old and new flags.
Follow-up to #6304. Resolves#6489.
Make some modifications to the adjust-audio-volume infrastructure:
1. Add an `aav_volume` array for ease of access to all three volume variables. Refactor `snd_adjust_audio_volume()` to use this array to avoid duplicating code.
2. Move `update_looping_sound_volumes()` to be handled in parallel with `audiostream_set_volume_all()`, and for the same reason: avoid setting the sound volume for every looping sound on every frame if the volume has not changed.
3. If the volume is to be adjusted immediately, apply the relevant changes without waiting for `snd_do_frame()` to be called on the next frame. Resolves#6291.
4. Fix some edge cases in `adjust_volume_on_frame()`.
As discovered by WouterSmits, campaigns with periods in their filenames caused issues with FSO's campaign handling. Specifically, in The Babylon Project, the EA-Minbari war v1.0.fc2 campaign would not save progress because FSO expected EA-Minbari war v1.fc2 in certain places. This is because the `_splitpath()` function attempted to remove an extension from a filename that already had it removed. For most campaigns this did not matter, but WouterSmits found a campaign where it did.
To solve this, there is now a new `util::get_file_part()` function to remove the path without removing the extension. This replaces `_splitpath()` for campaign files, as well as the similar `clean_filename()` and `GetFilePart()` functions in other places. All code paths were inspected for any chance of inadvertent extension adding, and Assertions were added to verify future code. The only potential problem area was `player:loadCampaignSavefile()` which now pre-removes the campaign extension if needed.
There were several bugs and design issues in the Vasudan headz cheat, probably due to being coded in a hurry right before release:
1. Although the cheat activated on the main hall, it was not immediately apparent, requiring the player to switch screens and come back
2. The detection of whether the main hall is Vasudan did not work after the cheat was activated, due to the background filename changing (this one is actually not Volition's fault)
3. The implementation of the cheat was actually in the wrong section of code, resulting in some confusion
These are now fixed. The cheat can be enabled or disabled from one function, the graphics are reloaded properly, and the main hall detection includes the cheat-active version of the main hall. Also, the door sounds have been slightly refactored to use a `std::pair` rather than a vector, since there are exactly two sounds, an open and a close.
This allows the current campaign to be set on FSO launch so that the
player isn't interrupted by the "The currently active campaign cannot
be found" dialog when changing mods.
Example usage:
fs2_open -campaign freespace -mod fsport
* fix some usages of std::transform
* change parse_string_flag_list to use a reference
* add a variant of parse_string_flag_list that can use a SCP_set, and make a templated version of flag_def_list
An idiosyncrasy of the original implementation of `timestamp_until()` is that "immediate" timestamps that expired would be negative. Only one remaining spot in the codebase relied on this: engine wash. When #6258 fixed `timestamp_until()` to return 0 for immediate timestamps, engine wash broke. Changing the comparison from `<` to `<=` fixes it. I searched the code and there are no similar uses of `timestamp_until()` or `timestamp_since()`.
In the process of searching, though, I found two uses of `timestamp_since()` that were converted from `timestamp_until()` in PR #4286. These particular conversions more properly include the 0 rather than exclude it, so I changed these as well.
Due to broken node iteration, the `sexp_ship_deal_with_subsystem_flag()` function incorrectly treated the first sexp node as a subsystem, but previous versions of the function would fail silently and ignore it, and subsequent nodes would work as expected. With the new `process_ship_subsystems()` function, this error is properly flagged (and the incorrect node is again bypassed). So, fix the error by fixing the node iteration.
Follow-up to #6221.
1. Allow the goal priority to be an evaluated number, not just a literal number. This allows the goal priority to be obtained from operators or calculations.
2. Since the priority can now be evaluated, it can be NaN. In that case, default to the max priority.
3. Consolidate `CDR(CDR(...))` to `CDDR()` in the aigoal implementation
4. Clarify that `remove-goal` removes the first goal of a given type and priority, not necessarily the first fully matching goal.
5. Enhance `remove-goal` to remove all goals matching the constraints, not just the first goal.
6. Allow `remove-goal` to disregard priority when checking for matching goals.
* Partially builds weapon curves.
* Further curve implementation
* Implementation of more output types.
* Cleanup
* Adjusts warning.
* Appeases clang.
* further appeasement
* Appeasement and time-traveling review changes
* change the enum branch too that'd be good
* More requested changes
* Basic abstraction for generic modular curves
* Make curve list by output statically sized
* Make instance-randomization consistent and mapless
* Add parsing
* Add derived modular curve sets
* Fix incorrect unpack
* Split modular curve set and definition, properly comment struct usage
* Split off specific type-traits into own file
* Fix modular curves for multi-derive case
* Implement some basic weapon curves, as well as the damage multiplier hit curve
* Merges in generified system built by Lafiel.
* Fills out beam curvesets.
* Renames curvesets.
* Removes launch curves for now.
* Testing, bugfixing.
* Various cleanup
* Returns extern do_subobj_hit_stuff
* Fixes compile errors
* Beam flag checking
* Rearranges beam flag checking.
---------
Co-authored-by: BMagnu <[email protected]>
A connection speed of "None" is really just the default used by launchers if the user hasn't explicitly set the speed yet. Additionally, `CONNECTION_SPEED_NONE` isn't really used by the engine except for error checking. So, fall back to the default connection speed even when the speed has been set to "None".
Follow-up to #6402.
Many SEXP operators that work on subsystems use very similar code. This new function allows the operator implementations to be streamlined and makes future modifications easier. For example, the `change-ai-class` operator now works with names such as `<all turrets>` as well as specific subsystems.
As described in #6445, the `warpIn()` script function did not work correctly for docked ships because the dock leader flag was not set. So, set the flag, but make sure to set it only for the first ship for which `warpIn()` is called. And make sure the flag is removed after the ship finishes arriving.
Also remove an `Int3()` in `shipfx_warpin_start()`. (This Int3() was not actually in the original Volition source code release.)
Fixes#6445.
* Add option to set a font size multiplier for ttf fonts
* remove the option if we have no scaling fonts
* Clang the conquerer strikes again
* Update XSTRs
* clang
* Clarify comments
Having a missing bolt texture is not fatal; TBP uses it for `b_invisible`. Modify the bolt checks to display a non-fatal warning if the bolt texture is explicitly specified but not found.
Many beams are lumped into the #Primary Weapons section of weapons.tbl, which will mark them as WP_LASER. Fix the few instances of code that are intended for beams that may have omitted most beams by mistake.
Randomization of weapon impact particle radius is also affected, but since this affects existing visual effects, it was not changed.
A recent-ish FSO feature, `$Turret Name:`, allows turrets to be displayed differently on the HUD depending on the weapon they carry. It is useful for scripts to be aware of this, so this PR adds a `TurretName` virtvar for weapon classes, as well as a `NameOnHUD` virtvar for subsystems. The `NameOnHUD` virtvar shares exactly the same code as the HUD uses, so any future HUD modifications will be reflected in scripting as well. This required a small amount of refactoring: changing `get_turret_subsys_name()` to return a value rather than stuffing a string, renaming it to `ship_subsys_get_name_on_hud()`, and moving it to ship.cpp.
This refactors FontManager to improve it in several ways:
1. Change all the dynamic memory management to use `new`, rather than mixing `new` and `vm_malloc`
2. Change the current font to use an index rather than a pointer
3. Take advantage of more C++11 features to avoid redundant lookups
4. Use case-insensitive name comparison
5. Avoid overflowing the `fnt->filename` field
6. Use `Warning` rather than `Error` in a non-critical error situation
1. Don't set the `can_use_for_bank` flag to FALSE if the bank is primary but the weapon is secondary, or vice versa
2. Make sure to only restrict the weapons by bank if the ship has per-bank restrictions
In support of this, add `is_primary()` and `is_secondary()` helper functions to `weapon_info` and use them in logical places.
Follow-up to #6434. Fixes a few subtle bugs from that PR.
When clicking on a weapon bank, mark the weapons as enabled or disabled according to their compatibility for that bank. Do not actually prevent the weapons from being selected and dragged, as they may be dropped on a bank that isn't selected.
Also add a new `TriStateBool` for situations where the value is true, false, or unknown.
Fixes#6398.
FRED has code to keep track of whether the main window should be rerendered on each frame. It looks like this was accidentally removed at some point.
(Discovered by comparing FRED source files while investigating #5568.)
A few addenda to PR #6364:
1. Use `std::swap` in the move constructor, since the fields are specifically being moved, not assigned
2. Fix off-by-one error when parsing firing patterns, and make the pattern count non-fatal
3. Standardize the setting of fire points since it's done in three different places, and in the case of `ship_set_default_weapons()`, `primary_firepoint_next_to_fire_index` was not reset to 0. It might be useful to refactor this code into its own function.
4. Make the setting of `primary_firepoint_next_to_fire_index` consistent between forward and reverse cycling
5. Remove a couple redundant `.clear()` calls and fix a typo
Any DDV (Dialog Data Validation) routine must appear immediately after the field it validates in order for the enforcement to work in real-time. If the DDV_ routine is not linked to the field, it will perform validation after-the-fact by displaying a dialog box and returning an error. This is an alternate way of handling validation, but in order for the dialog box not to generate an endless loop, it would be necessary to check the return value of every `UpdateData(TRUE)` call in the FRED codebase (or at least the first `UpdateData(TRUE)` in a pair of them) and then, if the return value is `FALSE`, doing an early return from the enclosing function.
Fixes#6427 as well as all similar cases in FRED.
The recent cycle expansion PR (#6364) causes a CTD when change-ship-type is used. This PR fixes that crash by using `pm->n_guns` instead of 'MAX_SHIP_PRIMARY_BANKS' and clarifies the definition comment for the `pm->n_guns` to help avoid this kind of quandary in the furture.
Tested and works as expected.
Adds a new `+Ambient Sound:` field to mainhall.tbl, allowing any interface sound (or even no interface sound) to be used for the main hall ambient sound. The default ambient sound, as well as the sound played on the pilot select screen, is interface sound 12.
Implements #6421.
If the mission is edited in a text editor, and a ship is given too many weapon banks, this can cause issues in the weapon firing code. Protect against this by checking the number of banks when the ship is created.
* Adds different firing patterns for weapons.
* cleanup
* further cleanup
* appeasement
* appeasement^3
* Requested changes.
* Deals with targeting flag issue.
* Resolves merge conflicts.
* blood for the blood god, tidy for the tidy throne
* Increments XSTR again.
Related to the previous two commits, the medals screen should use the actual all-time stats from the pilot file instead of the active campaign stats. This required tweaking the DCF "medals" debug command to work with the exported stats. Also, some C casts were changed to C++ and an obsolete variable was removed.
Related to the previous commit, the debriefing should use the actual all-time stats from the pilot file instead of the active campaign stats. In multi, however, use the active campaign stats; because the debriefing can display stats for different players, and all-time stats are only available for the local player.
Also, clean up and slightly refactor `show_stats_label()` and `show_stats_numbers()`. Duplicate code has been removed, string output has been streamlined, and a few bugs with percentages (especially divide-by-zero checks) have been fixed.
The FreeSpace AI includes behavior to run away from shockwaves to try to avoid explosion damage. This is implemented for both ships and missiles, although the missile implementation has been buggy ever since retail. There are several issues:
1. The AI attempts to evade a weapon immediately upon launch. Many missiles have a period of free flight before they start homing on their target. During the free flight period, the homing position is not set. Consequently, the AI will not know the position to avoid and will make assumptions.
2. The AI assumes the shockwave-producing weapon will detonate at the center of the ship it is targeting, although missiles detonate on the surface. A capital ship is likely to be significantly larger than the weapon's blast radius, leading the AI to believe the detonation will be much farther away than it actually is.
3. When avoiding ship shockwaves, the `shockwave_object` field is not cleared when avoiding is complete. This can result in stale references (though not crashes, due to object type checks), causing AI to not avoid future explosions in certain cases.
4. When avoiding ship shockwaves, the code does not check the correct ship for the amount of damage caused by the shockwave.
All of these issues are now fixed. Since this is a change in AI behavior, these fixes are tied to a new AI profiles flag.
The barracks should use the actual all-time/multi stats from the pilot file instead of the active campaign stats. Export the all-time stats from the pilot file in order to populate the barracks.
Follow-up to #6238.
```
code/menuui/barracks.cpp:188:8: error: type ‘struct barracks_buttons’ violates the C++ One Definition Rule [-Werror=odr]
188 | struct barracks_buttons {
| ^
code/menuui/playermenu.cpp:82:8: note: a different type is defined in another translation unit
82 | struct barracks_buttons {
| ^
code/osapi/osregistry.cpp:478: error: type ‘struct Section’ violates the C++ One Definition Rule [-Werror=odr]
478 | typedef struct Section
code/pilotfile/FileHandler.h:18: note: a different type is defined in another translation unit
18 | enum class Section {
```
This adds a sexp to allow any boolean condition, or series of conditions, to be evaluated not only instantaneously, but also for a period of time. For example, this can be used with `is-facing` to check if a ship has been facing another ship for a specified duration. Previously this had to be done through scripting or through a group of sexps.
Implements #5754.
When a player tries to skip a mission during a campaign, all goals and events are marked true. Thus it's possible for the campaign condition to unexpectedly *not* evaluate to the next mission (e.g. `if is-previous-goal-false` or `is-previous-event-false` is used without the optional argument). So add a failsafe check, with a warning, to handle this case. Also update the documentation to clarify that the optional argument is checked for the mission-skipped case.
Fixes an endless skip-to-the-same-mission loop discovered by ShivanSlayer in Shrouding the Light.
PR #6335 did not update actions/upload-artifact; both upload and download need to use the same major version number.
Also move from v4.1.7 to just v4 because that appears to be the common practice.
1. Use a sensible default for the connection speed
2. Remove the `Psnet_connection` variable which is now obsolete: "its only purpose now is to change the default object update value for a player if it's set to dialup, and that's easily done in-game already"
The "You must define your connection speed" popup will now no longer appear unless it has been explicitly set to an invalid value.
Applies recommendations from, and fixes, #6402.
Hide these SEXP operators to reduce confusion for FREDders. They still work, but using them properly requires a certain amount of knowledge of the inner workings of variables, and the operators can break if new variables are added causing the list to be re-indexed.
Implements half of #6400.
1. Since we already handle `<all engines>` and `<all turrets>`, it's simple to extend this to all generic subsystems of any type
2. Add an `<all subsystems>` case for handling every subsystem on a ship
3. Add some compiler directives to enforce preconditions for subsystem type `#define`s
There are a few places in the Lua script API where a variable could be some type of "object" or something that is not an "object" but is still useful - one example is the return value from oswpt:get(). With this function, scripts will be able to tell what the variable is without risking an exception.
* Fix AVX2 detection
* Also query for proper OS support
* Actually properly set ISA level on all platforms
* Expose level of x86-SIMD instructions to the code.
* Fix handling of forced instruction set
* Fix errors
* Fix MSVC
* Properly deal with linux CI builds
* fix clang
* Add support for RISC-V compile to cmake
* No need to pass -march for gcc in riscv
* -march=native is not supported in Risc-V clang
* fix comment and remove unnecessary newline
* Remove incorrect values while checking CMAKE_SYSTEM_PROCESSOR
* Support 32bit RISCV as well
I dont think this will be ever be needed, but i dont like that compilation will fail due to incorrect compiler flags if you try.
* Set ver to C++17
* remove deprecated shuffle
* Fix std::iterator being deprecated
* Work around codecvt deprecation
* Fix std::result_of deprecation
* Another random_shuffle
* another text conversion replacement
Takes the command-line arguments used to launch FRED and reuses them to launch FSO.
As part of this, slightly refactor the `cmdline_print_cmdline_multi()` function so that it calls a new `cmdline_build_string()` function.
The enhanced controls and flags in #4552 were intended to allow the camera to shudder in all views, not just the cockpit view. And indeed, the shudder does apply in all other views... except for cutscene cameras, due to the `VM_FREECAMERA` check in `game_render_frame()`. So, add a separate check for cutscene cameras when shuddering everywhere. The cutscene camera can be jittered just like the cockpit camera, but the rotation should not be modified or it will produce feedback.
Follow-up to #4552. Also removes an unused variable that was made obsolete in #5656.
This fixes the fighter/bomber type which had been broken ever since the objecttypes.tbl upgrade in 246cfcfa65: the fighter/bomber type is again treated as a union of fighters and bombers, not a unique type of its own. This requires special handling for the `OPF_SHIP_TYPE` SEXP argument type, and all four SEXPs that use `OPF_SHIP_TYPE` have been modified to check for the special case. The explicit fighter/bomber type has again been removed from the built-in objecttypes.tbl.
The requirements for "fighter/bomber" to be valid are 1) there is no explicit "fighter/bomber" type in the mod; 2) a "fighter" type exists; 3) a "bomber" type exists. If any of these conditions is not met, the special case behavior is not enabled.
Follow-up to #6390. Properly fixes#6388.
A few missions used the fighter/bomber ship type, so this adds the type back to make those missions work again.
Temporary fix for #6388. A more proper fix will be applied after the official 24.2 release.
This is already done in `movie::play()` and shouldn't be done again if a script overrides the function. The extra calls were added in 251285cacc and cbccf655fa (the former copied from the latter), originally as an unsuccessful attempt to fix Mantis 61.
Add an `$On Movie About To Play:` hook to match `$On Intro About To Play:`. Also make the two hooks overridable, since that might be useful.
Additionally, change a few (nonexhaustive) `name` parameters to `filename` to make it clearer that the string is a filename.
Augments the voice acting manager to handle non-wingman as well as wingman personas, plus limit operations to a specific persona. This also modifies the editor to only increment the number of modifications when something *is* modified, not merely when something *could be* modified but is currently the expected value.
Resolves#6379.
The XSTR entry 1779 (strings.tbl) is used for two different texts:
"Disabled" in shadows.cpp;
"Toggle Auto Pilot" in controlsconfigcommon.cpp;
"Disabled" is already assigned to XSTR 413. ATM I have this set to shadow's usage (even though 413 is related to Disabled ships). Alternatively I would be happy to use `"Off", 1693`, which is what the other graphic settings use (though the actual value in the code would still remain `Disabled` of course).
This adds several missing initializations of cargo titles for both ships and subsystems. Note that `Subsys_status` initialization needs to happen in `allocate_subsys_status()`, because subsystems can be allocated in red-alert or in the `ship-copy-damage` SEXP, not just parsing.
Follow-up to #6000. Fixes a rather insidious ERANGE error in Inferno.
1. Tweak the API of `error_display` so that an error level of 2 displays a `ReleaseWarning`.
2. Use this error level for the malformed XSTR warnings in the localization code.
Resolves#6374.
* Remove unneeded comment on U and V axis. (Comments there are for original axis XSTR indices)
* Fix UI issue where bound button message did not display which controller it belonged to
* Removed unused extern reference of Joy_button_text
This makes it so that the "3D"/"2D" display is actually respected in the in-game options menu, rather than just having an ambiguous checkbox labelled "Shockwaves".
The "stealth" and "fighter/bomber" ship class flags are not actual ship types, so they should never have been added to objecttypes.tbl. Remove them from the built-in table.
Additionally, if a mod *does* use "stealth" in its own objecttypes.tbl, remove it. This prevents the invalid "stealth" type from overriding a valid existing type, which fixes#6366.
When actions in the Voice Acting Manager modify the mission, set the modified flag so that FRED will prompt to save the mission. And since this requires tracking the number of modifications, enhance the dialog boxes to display this information to the user.
Fixes#6362.
Several locations in the code (notably `ai_info` and `waypoint_h`) previously stored pointers for waypoints and waypoint lists that need to be valid for more than one frame. Since both waypoint lists and waypoint paths may change size, resulting in vector reallocation, the information should be stored as indexes instead.
Fixes#6353.
Apparently virtvars can only return one value. This deprecates the virtvars and adds function equivalents for getting weapon class swarm info and corkscrew info. Fixes a bug reported by Woolie Wool in Discord.
The warning for mismatched names-and-indexes implicitly assumed that retail-style sounds would only be added with numeric indexes. Since adding named sounds in the retail style is, in fact, allowed, update the logic to not warn in that case.
Fixes#6354.
1. a `hud-reset-color` SEXP operator, to complement the existing `hud-set-color` and set a gauge back to its configured color
2. `ConfigType` and `ObjectType` Lua virtvars which are essentially the built-in gauges' equivalents of `Name` for custom gauges
3. `getColor` and `setColor` Lua functions
Since the `OPF_ANY_HUD_GAUGE` type checks for any default or custom HUD gauge in regular SEXP operators, it should do so in scripted SEXP operators as well.
Fix a small oversight from #6112. In the empty/placeholder indexed sound situation, although the sound should not be appended (since it indexed), it should still be treated as a new sound, in order for all the first-parse and first-initialize logic to run properly. Set the right value and add some comments to illuminate the logic.
Fix the inadvertent swapping of the two utility functions for parsing sounds. While we're at it, streamline a few lines, remove a few C-style casts, and remove an unused function prototype.
Follow-up to #6314. Fixes a crash encountered by Inferno on 24.2-RC1.
Per the comment earlier in this function, both -1 and -2 are expected values for sound indexes. Update the sound validity check accordingly. Fixes an assertion in `obj_snd_delete()` encountered by FotG when a sound index was -2.
* upgrade asteroid sexps to match new asteroid field features
* clang is a needy boy
* unify the sexp operators into one since there are minimal changes
* cleanup for readability
* address feedback
* keep from crashing
* Also, bash the number of waves if necessary
* Add Debug warning to modders
* address feedback
* formatting
---------
Co-authored-by: Goober5000 <[email protected]>
The BWO fix in PR #6317 was not quite the correct fix. The `sim_room_lines` array contains the maximum number of scrollable lines, not the maximum number of lines on the screen at one time. This partially reverts commit 20338ff28b and implements a new fix that allows the full `MAX_LINES` but also properly checks the list button limit. Additionally, this adds the list button limit check to other vulnerable code sections.
Fixes the tech room being limited to a single page of missions after #6317. Testing confirms that the BWO crash is still fixed with this update.
This is an error that existed all the way back in retail. Each line in the simulator room (i.e. each mission name in the list) is also a "button" in the sense that clicking on it will highlight the line and set some values. The maximum number of buttons is `LIST_BUTTONS_MAX`, but the maximum number of `sim_room_lines` was a different #define, `MAX_LINES`. This was set to 200, a far higher value than the `LIST_BUTTONS_MAX` value of 42. The code responsibly checked the limit, but the limit was incorrect.
(This had not been seen in previous mods because the number of lines was never high enough to reach 42. BWO happened to use a font that was small enough to fit that many lines in the mission simulator screen. This explains why removing fonts.tbl prevented the bug from occurring.)
Thus when the number of lines reached 42, the sim room started writing to out-of-bounds memory. This didn't cause a crash immediately, but did corrupt the `Static_lights` vector, which in turn caused a crash as soon as a model was lit in-mission or in the ship loadout screen. It's rather strange that this crash only occurred in optimized SSE2 builds though.
The fix is simply to use `LIST_BUTTONS_MAX` as the limit, rather than `MAX_LINES`. This also removes the unused `MAX_DESC_LINES` and `Num_desc_lines` at the same time.
Fixes#6313.
1. Make sure the legacy `timestamp_until()` and `timestamp_since()` functions check for any type of invalid timestamp
2. Add a useful `isFinite()` function
3. A timestamp delta on an immediate timestamp is more properly the actual delta, rather than another immediate timestamp
Add options to the Edit menu to lock and unlock objects. Locked objects cannot be selected or dragged. They can still be edited in the various editors (e.g. Ships, Objects) but not in the main viewing area.
Also add the Selection Lock option to the Edit menu. It was previously available in the toolbar but this provides another way to access it.
When the Show Waypoints option is toggled, the marking was not updated as it was for the other options (Show Ships, Show Starts, Show IFFs). Fix this by calling `correct_marking()`.
* Cleanup variable name in `weapon_do_area_effect` function
Per discussion in #6302, this PR renames `other_obj` to `impacted_obj` to minimize confusion
* update other functions with impacted_obj naming
* nullptr
* appease clang's strange rules
* fighting clang continues
* use !empty check instead of > 0
* remove un-needed no lint comment
Per #4294, this adds two new flag that, together, are equivalent to the legacy "immobile" flag but individually provide more fine-grained control. Since the physics for position and orientation have a bit of overlap, the new flag functionality simply reverts whatever position or orientation changes were done by the physics sim.
In the FRED and qtFRED ship flags dialogs, the "immobile" flag (aka "Does Not Move") is replaced by the two new flags, but in FSO the situation is more complicated. The old and new flags coexist and have overlapping functionality, so the mission designer must be careful to set and unset the appropriate flag (that is, it is possible for both "immobile" and "don't-change-position" to be set at the same time, in which case the ship cannot change position without both flags being unset). The `set-immobile` and `set-mobile` legacy SEXPs ensure that the new flags are removed so as not to conflict with the legacy flag, but the `alter-ship-flag` and `are-ship-flags-set` SEXPs and the `getFlag` and `setFlag` script functions use exactly what the FREDder/scripter specifies and nothing else.
(I attempted to completely replace "immobile" with the two newer flags, but it proved intractable to do this while maintaining reverse compatibility: retrofitting single-flag functions to apply dual flags for one particular situation made the functions harder to understand as well as introducing many edge cases and opportunities for bugs or "gotchas".)
Implements #4294.
* Fixes CTD with new Friendly Fire Feature
On current master I was hitting a CTD when firing a weapon with a shockwave at close range (ie player is within the shockwave zone). The minidump showed `other_obj` was null, so this PR adds some safety checks.
Tested and this fixes the crashes.
* fix obj usage
* one more obj cleanup
Prevent compiler warnings caused by the `value` parameter of the external serializers hiding the `value` member of `std::integral_constant`.
Follow-up to #6276.
* Adds particle effect offset.
* bugfixing
* Switches to a cleaner approach.
* Futureproofing for particle parenting.
* actually let's just bundle parenting into this one
* working on turrets
* grinding toward turret correctness
* still grinding toward correctness
* Gets turrets working correctly.
* Fixes merge artifact
* appeases clang-tidy
* Updates some comments.
* Updates some comments.
* Tiny bit of cleanup.
* Deduplicates comments.
The return value of `lua_tostring()` is NULL if (and only if) the string conversion failed. Many places in the code did not check for this situation, which led to the crash in #6290.
Fixes#6290.
* Adds curves for slash completion and rotation.
* Finalization.
* Fixes pointer comparison.
* Updates table parameter to better match behavior.
* Makes requested changes.
* Changes rotation amount to use raw curve.
* Sets curve-1.0 to be equal to full turn rotation.
As noted on Discord, there was previously no `is-species` operator. Now there is.
As a bonus, this also fixes a bug where the pre-existing `is-iff` operator did not work with wings that had not yet arrived.
This fixes an edge case in the Average and Multiple modes, where secondary lead indicator rendering was skipped by continue statements when the primary weapons were out of range. I also added some comments that help people actually understand what this function does as it is very confusing.
Although sound indexing is now done by name, mods which index by number (sc. a number that is treated as a name) expect the indexes to be in numeric order. When multiple levels of -snd.tbm files add mixed retail-style and new-style sounds, this assumption can be violated due to named sounds being placed into indexes that later files expect to be available.
This PR refines the parsing so that sounds which use a numeric index can pre-empt existing named sounds that have been assigned to that index. Since named sounds can go anywhere, they are just moved to the end of the list. This allows the ranges 192-199 and 202-249 to be available for numeric indexes as expected under the old style. MediaVPs named sounds which were previously parsed into those indexes are bumped to the next available index.
Additionally, this PR doubles the range of numbers that are treated as indexes, to more realistically accommodate additional numbered sounds. (The number/index distinction is rather arbitrary and is primarily used to avoid creating large sections of unused sounds if a mod were to specify a very large number, e.g. 10001, for a sound name.)
Finally, this changes parse warnings to use `error_display()` so that the warning displays the parsed file and line number.
Fix units are denominated in seconds, while timestamp units are denominated in milliseconds. This fixes the directive timing check which, after the timestamp upgrade, would time out after 5 and 7 milliseconds instead of 5 and 7 seconds.
Follow-up to #4633.
* Sets up linear interpolation for object particles.
* Makes interpolation time-based.
* Updates comments to match changes.
* appeases clang-tidy
* Adds interpolation for particle particles.
Model textures that are too long will cause a very unfriendly and hard-to-track down "ERANGE: String" error. The situation can be greatly improved by checking the string length ahead of time, printing a friendly Warning, and truncating the filename. This will alert the modder to the source of the problem while also allowing gameplay to continue.
This would crash because duplicate sounds were not being populated with the original entries. When snd_set_pos was called, the handle to the Sounds array would not be set, making our code think it was not loaded.
This was motivated by the recent Coverity report. Coverity noticed that a few of the copy assignments could be replaced by move assignments, but on further investigation one copy each in `ship_weapon_check_collision()` and `beam_collide_ship()` can be entirely removed, another either/or copy in each can be replaced with an either/or pointer assignment, and a few copies can be done only when needed. Another vec3d copy (`hit_dir`) can be replaced with a vec3d pointer; it is no longer modified locally, so there is no longer a need to keep a local copy.
According to DahBlount:
> Most atan2 implementations for a long time had problems when the inputs were close to machine epsilon or when x was less than or equal to 0
And according to z64555:
> Modern versions of C++ should have an atan2() that works correctly when the inputs are at 0 or near epsilon of the floating point specification, meaning Volition's workaround shouldn't be needed anymore.
So this removes `atan2_safe` and changes all instances to `atan2`. Consequently, the angle range in FRED now shows as [-180, 180] as expected.
Fixes#3730.
The somewhat modern AI flag for `Require_exact_los` is extremely useful in multiple different situations, for example making large capital ship weapons not fire into friendly surrounding ships on accident. When the feature was added, the `check_los` function was provided with a default value of `10.0` meters for minimum radius detection. This PR exposes that value to modders so they can set it to a reasonable value depending on the ship sizes of their specific needs. And as a note, the los value just uses a simple numerical comparison check, so the los detection could be set to a negative value with no consequence (hence why error messages were not added, though if folks would like I can certainly add them).
In retail, the processing of certain keys during a popup, in the `popup_process_keys()` function, was dependent upon the `PF_ALLOW_DEAD_KEYS` flag. This flag was never used in retail, causing the if() block to be marked as dead code. In a4e623db23, the dead code warning was addressed by removing the dependency on `PF_ALLOW_DEAD_KEYS`, which is incorrect. The "dead keys" should only be processed during the "dead popup". Since the "dead popup" was moved to its own de[a]dicated "popupdead" section, the "dead keys" processing can be entirely removed from the "normal popup".
Fixes a bug noticed by @PremiumColt where certain keys, especially the time compression keys, were processed while the ESC popup was active.
This prevents Coverity from running on any forked repository, by default; both because the workflow will fail, and also because the workflow's results would be identical. (Any forked repository can, of course, change this within its own scope.)
In `strings.tbl` the graphics settings localization IDs are as follows:
1160, "Low"
1161, "Medium"
1162, "High"
1163, "Very High"
These values are used throughout the code, but in some cases with SCPUI upgrades, the IDs got off by 1. This PR fixes those incorrect IDs.
Supports newer SDL2 from the prebuilt package on win32/win64
Adds support for Windows ARM64
Adds option to use prebuilt SDL2/OpenAL/Freetype libs on Linux
* 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
In current master, the debug log commonly shows `CSG => Warning: (0x0011) Short read, information may have been lost!`.
Thanks to Taylor for pointing the following issue out:
The function `pilotfile::csg_read_redalert()` returns if `ship_list_size` is zero, but it still needs to check the `wing_list_size` a bit below that. This has likely not caused data loss issues ATM, because it's reasonable to assume that if `ship_list_size` is zero then so is `wing_list_size`. But it's still a bug and should be fixed before it does cause some real data loss.
This PR moves the relevant read sections to within each respective if-block. That way the function is capable of checking both `ship_list_size` and `wing_list_size` on every load (even if `ship_list_size` is zero).
Per @notimaginative, change the `compiler` variable to uppercase to match its usage in the rest of the file. This should allow the coverity task to start running again.
I took a close look at the code involved in parsing particle tables. There is no smoking gun, but there are several ways to polish the code which I have implemented here. The most likely culprits for the slowdown, IMO, are the repeated conversions between SCP_string and C-string, especially in `ParticleManager::getEffectByName()`; followed by the omission of `std::move` in several places.
Adds an optional argument to the `lock-perspective` sexp to allow locking of the 'free look' or 'padlock' view. This prevents the player from looking around which might not be desired in certain forced perspective situations.
When loading a legacy mission that contains a debris field, FSO will try to index into an empty vector, causing an out-of-bounds exception. This can be seen by loading Derelict mission dl1-08, "The Horror in the Deep".
The `// Obsolete and only for backwards compatibility` code added in #6021 properly handles asteroid fields, but not debris fields; so the fix is simply to apply the logic to debris fields as well.
Patches the gamesnd system in several ways to properly fix the bug identified in #6196. Due to the way the new sound system was written, sounds with numeric IDs were not necessarily added in their indexed location, even though the code assumed (even prior to #6112) that this would be the case. The code now uses the proper index for both old *and* new style sounds. This is done by ensuring, in `gamesnd_parse_entry()`, that the vector contains an entry for the specified numeric ID before doing a search for that ID.
Due to the slightly modified population of the gamesnd vectors, the `Snds_iface_handle` vector is now populated after parsing the various sounds.tbl files rather than during parsing.
Separately, this makes consistent the handling of the `sound_entries` vector which could potentially be empty but also treated an empty state as an assertion failure.
#6187 fixed transparency for cockpits, but the positioning for deferred lighting alas fell through the cracks. This PR fixes that and allows deferred lighting in cockpits to once again work as intended.
Tested and fix works as expected.
When a new mission is loaded, clear the parse names vector, in lieu of the old `Num_parse_names = 0;` line. This fixes a bug where FRED will complain about nonexistent ships when loading a different mission. Follow-up to #5937.
* One more follow-up to #6021
Update assertion message and mission saving check since older builds are not going to be able to read fields created with newer builds
* update to use empty
The Unlimited Asteroid/Debris Field Types & Subtypes PR (#6021) updated to using vectors to allow for unlimited asteroid and debris types. That update removed the count field, `num_used_field _debris_types`, which counted both asteroids and debris pieces (even though the name only has debris in it). The counter variable was removed in favor of `.size()` but now both asteroid and debris field sizes needed to be checked, so this PR updates the code to account for that. Allows asteroid fields to properly pass the count check and properly again spawn in mission.
Tested on asteroid fields passive and active along with debris fields (both created from sexps and the asteroid mission editor) and everything now works as expected. Also tested on missions with no fields and those also still work as expected.
Break when you've found a match, instead of just mindlessly comparing the rest.
This is technically just an optimization and safety change, but potentially, before, if the loops had been switched, it would have caused unexpected behavior if two copies of the same flag were listed.
The header length from the tracker is 1 byte larger than the size calculated
by the client due to psnet removing that byte internally. The header length
is adjusted to compensate for this, but only *after* the deserialization
process, so we have to use the received packet size instead.
* Remove old interpolate angles quick
* Remove old interpolate functions
These are no longer used.
* Add linear interpolate vm function
More clearing functions
* Add physics snapshot struct to silo interpolation
Two of these two functions require an object pointer, so they cannot be in physics_state.cpp
With doxygen documentation
* Try to placate Linux
* Address Feedback
* And update declaration, of course
* Attempt to appease linter
* add API for glow point banks
Previously, a model API existed for glow points mounted on thrusters, but not glow points mounted on glow point banks. This adds glow point bank support. Also, this refactors and cleans up the implementation of the model API a bit.
* NULL -> nullptr
Should allow for most games, even those behind CG-NAT, to work without having
to set up port forwarding. This set of changes is only needed for game servers
to work with the new feature. No special handling is required for clients, so
any build from the last few years should work for them.
The new `ai-disable-ship-tactical` and `ai-disarm-ship-tactical` goals were inadvertently omitted from the ship type default table, causing these goals to not be available in the Event Editor drop-down menu or Ship Editor initial orders. Testing did not catch this because testing was done using the HUD squad message system which assigned the new goal (if the flag is enabled) without explicitly checking the validity.
Follow-up to #5512. Fixes#6189.
* make mission log dynamic
Change the mission log from a static array to a dynamic vector. This removes any chance of the mission log running into a limit (as regularly happened with the last mission of Shepherds before the limit bump) and also prevents strange mission bugs caused by culling obsolete entries.
This also unifies the API a bit by renaming the public `message_log_` function prefixes to `mission_log_`, removing the redundant `Num_log_lines` variable, and removing `Log_scrollback_vec` from the header.
Implements #5878.
* feedback
* refactor to reference rather than pointer
* base working version of unlimited debris types
* Proper FRED support
* make qtFRED handle asteroids properly
* fix qtFRED assertion
* further clean out MAX_RETAIL_DEBRIS_TYPES
* These should be sizes not POFs
* Move this to it's own method
* convert asteroid subtypes to a vector
* unlimit asteroid subtypes
* fix some global shadowing
* signed/unsigned mismatch
* Address feedback
Fixes a bug with new unified scanning PR (#6000) and adds a bit of cleanup, including consistent brackets, whitespace cleanup, and removing vestigial function from the original PR.
Tested and works as expected.
* disable popen
* Check file type when opening with io lib
* Compile on Windows
* Windows include
* Properly conserve function environment
* Correctly copy fenv
* Move these functions into OptionsManager for more global use
* Make sure player options are preferred even when using OptionsManager
* persist the newly loaded options to disk
* Actually let's persist these only if the load is successful and also handle the multi option
* Comment this out for now I guess
This refactors the object_h struct to store objects as indexes rather than pointers. This is a prerequisite for making the collection of objects dynamic in the future. See also #6100.
Follow-up to #5800 and #5829.
* Save/Load player options to a mod-specific ini file if possible
* use rfind instead of find to ensure it's the last dash character used for trimming
* cleanup + comments + nullptr
* A more robust way of getting the mod root using lambdas
* prevent infinite loop for non Knossos/Knet mods
* Notify the player if options may need updating and pull settings from fs2_open.ini if we can
* proper localization
* update xstr
Inspired by #6178, this moves the existing `count_items_with_name()` functions into utility.h and adds additional functions for finding specific items with a given `.name` or, more generally, a given field. The `Damage_types` search has been converted to illustrate how these functions can be used.
* Expose Impact Damage Type to Scripting
There's already a sexp that does this, but having the script version for ships is quite useful, too. For example, scripters can set impact damage types for just the player at various difficulties.
Tested and works as expected.
* always set damage type
* Exposes the New Flight Cursor Mode to Scripting
Thanks to #6136, FSO supports switching between two methods of flying. This PR exposes those settings and values to scripters. Tested and works as expected.
* fix aiming setting
* add reset position function
* cleanup setting pitch and heading
* one more cleanup
* update to enum support
* remove older version
* one more fix for setting flight mode
* Clean unneeded properties
* properly queue-ify keys
* Refactor key checking to use functions instead of globals
* Update hooks and cache checked-against key
* Documentation and Naming
* match tilde
* only remove control not debug
* Move replacement textures from ship to modelinstance
* Actually set pmi
* Fix texture replace in fred as well
* Fix bad indent
* incorporate feedback
When game sounds were changed to allow named entries, it became possible for named entries to unexpectedly replace numbered entries. This was noticed most obviously in the ballistic rearm sound effect, which started using explosions rather than the standard rearm sound effects. This occurred because MV_Tiny and MV_Small were added into indexes 200 and 201.
To restore the original behavior, the code now prevents sound effects added via TBM from being placed into reserved indexes. The reserved indexes are instead assigned placeholders, which can subsequently be updated or left alone as the modder prefers.
This also makes the code a bit more robust including patching some sound validity checks in `gamesnd_game_sound_try_load` and `snd_load`.
Considering that we have `ba.createRandomVector()`, we should have `ba.createRandomOrientation()` too. This is based on an algorithm devised by @Baezon.
When messages are distorted due to EMP effects, the voice volume should be controlled by the voice setting, not the effects setting. Fixes a bug noticed by @skdKitsune, a portion of which dates back to the original public source release.
Also, when volume is adjusted in `snd_set_volume`, make sure the correct voice volumes are used. Fixes a copy-paste bug from #5694.
The three functions `physics_apply_whack`, `physics_apply_shock`, and `physics_collide_whack` limited speed after the physics had been applied, but they limited absolute speed, not the speed due to the physics. This modifies the process to limit the change in speed. It also adds an AI profiles flag to disable the limit if desired.
This also tweaks the three functions (by editing comments and moving lines) to be more consistent, since all three are doing very similar calculations near the end.
* Expose Collision Rotation Factor to Players
Previously, there were hardcoded checks in place to make players have 0 rotational effects when colliding with another ship. This PR adds a new value, "+Player Multiplier for Rotation Factor:" that allows modders to have players experience rotational effects from collisions. Also performed some cleanup of the light and heavy collisional rotational calculations by removing older if-blocks following useful recommendation from Asteroth.
Tested and works as expected.
* make rot_fac_multiplier_ply_collisions into global value
* update name to better match with ships table
* restore repeated comments to help with separation
Follow-up to #6047. This method better accounts for matching the guardee ship orientation when using the new AI flag.
Tested and works as expected. Thanks @BMagnu!
1. Add the "Override #Command in event messages" checkbox to qtFRED
2. Add the "Preload Subspace Tunnel" checkbox to the proper button group in qtFRED
3. Reorder lines in fred.rc so the declarations match the order they appear in the dialog
4. Use the correct name when reporting fireball index errors for ship classes
This provides a command-line argument to restrict the time compression range to the classic 1x - 4x. Implements #6075.
I'm not entirely satisfied with `-orig_speedx_range` but it's the best I came up with that fit into the 19-character limit. I'd be open to other suggestions.
Rework `hud_support_find_closest()` slightly to do a quick out if the player is no longer a valid object. Fixes an assertion noticed by Darius that occurs if the player dies when a rearm is imminent.
Make the initialization sequence consistent so that FSO, FRED, and qtFRED call their initialization functions in the same order. Most of the changes involve bringing FRED and qtFRED into sync with FSO. This fixes fireball prerequisites for the ship types table, applies the script initialization fixes from #5946 to FRED, and generally removes the possibility of any surprises due to FRED differing from FSO.
Also remove the empty `brief_init_colors()` function.
1. fix a bug where blips expired immediately every frame; they now track their expiration by object
3. store object numbers rather than object pointers
3. clamp both the high bound and the low bound of alpha values
Convert `sweep_duration` from seconds to milliseconds to work correctly with the timestamp system. Also clarify use of `game_get_overall_frametime()`, especially with `ba.getFrametimeOverall()`; and add `ba.getSecondsOverall()` to do what `ba.getFrametimeOverall()` allegedly did.
Allow the resize mode to be specified to `gr_set_clip()` without changing the active graphics-wide resize mode. Along with `drawStringResized`, this provides a shorthand to allow text to be drawn at different sizes, with the appropriate clipping regions, without requiring access to the `CurrentResizeMode` virtvar.
As requested by Event Horizon, this removes the limit on fireball types. The fixed array has been replaced with a vector and the relevant code updated accordingly. There is also a new version of `stuff_int_list()` to parse ints into a vector.
This also adds bounds checking for explosion animations that are parsed for ship classes, ship types, and asteroids, since previously there was no guarantee that the indexes would be in range.
This is a follow-up to #2942. That PR solved most of the short-circuiting issues with nested conditionals under when-argument, but it was still possible for the code to incorrectly short-circuit on a nested conditional that had `<argument>` in an action operator but not a condition operator. The cleanest way to fix this is to not short-circuit on *any* nodes that are part of a when-argument tree.
First step in the process of working Windows ARM64 support. This adds the most
basic support needed, but by itself will not succesfully build. However these
changes should not interfere with builds for other architectures or platforms,
and should still allow for x86/x64 builds on ARM64 Windows.
Remarkable that we're still finding bugs in fighter beams after 20 years...
Since field-of-fire angles are specified in degrees, and `cosf` accepts radians, the angle needs to be converted (and then halved, per usage elsewhere). Although this is a bugfix, this should technically not affect fighter beam behavior because fighter beams always fire down their normals.
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.
To enforce type safety for arrival and departure locations, this converts them to enum classes. Various casts are added when appropriate to convert between the indexed and enum values.
Allows ships and wings to arrive behind a ship, to complement 'In front of ship'. In fact, the arrival code is nearly identical, with just a small tweak to distinguish ahead from behind.
Since the new arrival location represents a change in mission format, this also adds code to detect for its usage and set the mission format to 24.1. Most missions can continue to be saved as version 23.1.
* Improve Mainhall Button Responsiveness
Previously, there was a 175 millisecond delay when hovering over a mainhall animation before it triggered. This PR makes that value settable via the mainhall table.
Tested and works as expected. Now custom mainhalls have much more of a spring int their step.
* cleanup num res location
Indexes are a more robust way than pointers to manage model and submodel handles, and in the event that models are made dynamic in the future, indexes will be necessary anyway.
Set the bad node to the ship node, so that the FREDder can see which ship is receiving the invalid order. Without this change, the bad node would point to the last value parsed, which is typically the goal priority.
Fixes a misleading error dialog reported in Discord.
When attempting to add a chat message which is all whitespace the split_str()
function will produce no lines. The strcpy() that follows will then crash
due to an attempt to copy a nullptr.
Adds bcdec lib to convert compressed DDS textures to RGBA based on what the
system supports. BC7 if BPTC extension not supported, DXT? if S3TC extension
not supported.
Should support cubemaps and volume textures but those were not tested.
Addtional changes:
- remove indexed DDS support since it had bugs but didn't work anyway
(R8 should be used instead)
- fix issues with volume textures (nothing to test with)
- remove old compression support flags as they are now obsolete
Fixes#4920
Follow-up to #6034. This slightly changes the function signature of `AddElectricArc` but it should be fine since it hasn't appeared in a stable release yet.
* multi host settings ui initial setup
(cherry picked from commit bcb31c327653329e62e4430815fe1e981751f9dc)
* Finish the rest of the API
* include enums
* set these
* Close game needed
* Handle accepting the host setup
* Don't need to be master to set these and add ways to check master and self
* add client ui to this PR because
* Allow getting the player state string
* Multi sync api methods
* unused variables
* Fix state checking
(cherry picked from commit fcde973cdf)
* typo
* address feedback
(cherry picked from commit ecb33e7cc6)
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.
Add a routine to the sexp syntax checker that also checks for potential issues. These are not definitive errors, but situations that might trip up mission designers. Currently there is one issue checked: the destruction of a wing that has multiple waves and arrives from a docking bay.
This does two things:
1. Fix a bug in `mission_bring_in_support_ship` that assigns an incorrect parse object index to the support ship's ship registry entry. Since `Arriving_support_ship` is not an item of `Parse_objects`, it should not have an index.
2. Adjust the in-game join checks at the bottom of `parse_create_object_sub` to more scrupulously account for index mismatches and bounds errors, with a specific exception for the arriving support ship.
Thanks to @notimaginative's detective work, nearly all of the FRED stalling when saving a mission can be avoided by simply not calling `model_free_all()`. By checking a flag in `clear_mission()`, multiple situations can avoid this slowdown, including reload-after-save and import-FSM.
The model was not updating its sending to front end list when getting new info from user input. It would save it in the model, but not where it was sending information back to the dialog (UI).
The logic to handle the `$Fixed Missile Detonation:` flag missed an important case: subsystems with concave hull geometry but without destroyable submodels. The original flag was tested on a bowl-shaped turret, which could be destroyed. However the bowl-shaped engine on the SSG Rahu was susceptible to the same detonation problem. By changing the check to always use the radius, whether obtained from a submodel or from the subsystem, the flag fixes the detonation in both cases.
With the `$Damage Impacted Subsystem First:` game_settings flag, weapons will damage submodels over subsystems, even if the subsystem is closer. Yet occasionally this is not the correct behavior (e.g. for the Rahu's engines). The new subsystem flag allows this behavior to be selectively overridden.
Fix a minor oversight from #6014; in the ship lab, there are sometimes no suns at all, so remove the assertion. The lighting check is only needed for supernovas anyway, so make that clear.
Additionally, add further clarification for the distinction between suns, lights, and variables used only for the supernova. Finally fix one more sun/light discrepancy that escaped notice from #6014.
Fixes an assertion in the ship lab. Follow-up to #6014.
* add cockpit fov to in-game options and use a define for the default fov value for both fov options
* Add a controlling toggle option
* constexpr
* localization
This adds the special SEXP return values (SEXP_KNOWN_TRUE, SEXP_NAN, and so forth) as enums, and adds code to intercept these enums if they are returned where the code would normally expect a boolean or number. If an enum is found, it is converted to its special return value equivalent.
With this change, a script can end a function with `return SEXP_KNOWN_TRUE` or similar. No other API changes are needed; in particular, no special `$Return Type:`s are needed.
Implements #5959.
In #5894, in the `add_dynamic_sexp` function in sexp_lookup.cpp, a call to `sexp->getHelpText()` was moved to the bottom of the function. Normally this would be fine, except that this occasion caused the `sexp` variable to be accessed after a `std::move`. The crash can be avoided by moving the last access of the `sexp` variable just a little bit earlier.
This allows the skybox orientation and alpha to be accessed and changed through Lua virtvars, and also adds a sexp to change the alpha.
Unfortunately, changing the alpha has no perceptible effect on the skybox. This will need the attention of a graphics coder to figure out what might need updating.
When waypoint start index and direction were added in #5698 / 42fc989 et seq., the `Fix_ai_path_order_bug` flag needed to be updated to account for those new options. This fixes that.
Fixes#6052.
Since the On Ship Collision hook can potentially be called twice, with the ships reversed, it is necessary for both parameters to have submodels specified. Otherwise +Override would not be able to handle both cases.
Followup to #6035.
* Add AI Flag to `align to target when guarding stationary ship`
When a ship is ordered to guard another ship that is stationary and not incredibly large, the AI will fly to a position then turn and face away from the targeted ship. This behavior is not ideal in various scenarios, including both blockade style formations and overall visuals.
The PR adds a flag that tells the AI to align to the target ship it is guarding once the AI has reached it's guarding position in this situation, which allows all the guarding ships to have the same orientation and look much better and work better for directional defenses.
Tested and works as expected. Also changed some `NULL` to `nullptr` in this function for cleanup.
* remove duplicate brackets
* convert multi team chat to use a struct/list setup
* use the correct array size define
* cleanup local vars & Asserts
* address feedback
* remove uncessary if
* multi pxo api
(cherry picked from commit 9af26da728a19b9d6c890968a314e8e56ecc1ddf)
* multi pxo help api
(cherry picked from commit f4df704576ddb648e9c486907b07ae172c859feb)
* minor fixes
* not extern
* break out chat message data into a table
* address some feedback
* return empty strings if not in multi
* use GetChannelByUser() instead
* once more with feeling
* correct documentation
Kind of surprised this SEXP operator hasn't been added before now. It complements the existing percent-X operators in the Objectives category.
Also, this fixes and clarifies the help documentation for the various percent-X operators.
Turn `Parse_names` into a vector and add SCP_string overloads of ship registry functions. Refactor calling code to use registry as appropriate. Remove an unused overload of `mission_parse_get_parse_object`.
* Add the submodel that was hit to the On Ship Collision scripting hook. (This will only be non-nil if the ship was the "heavy object".)
* Add a `getModel()` function to the scripted submodel object.
* Fix some incorrect documentation in `OnShipCollision`.
* Expose NoCollide and NoCollideThisOnly as virtual variables for submodels
* Allow submodels to be optionally specified in object:checkRayCollision
* Be sure to calculate ship-to-ship hit position before the override collision hook is called, in case the hook needs this value. (The other collision hooks already calculate the hit position before the override hook.)
- Set app name properly per Apple docs
- Use correct "FreeSpace Open" name
- Set version properly per Apple docs
- Add bundle identifier
- Update copyright date
- Remove localized strings since they are all English already
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.
* Fix CTD with HUD Preset Switching
After #5302 it was discoved that pressing the `Next` button in the HUD presets would cause a CTD.
Thanks for Lafiel for figuring this out
`If HC_current_file is HC_preset_filenames.size() - 1, then it'll oob on a vector access.`
Testing this PR fixes that crash.
* use static cast
* add extra ways to modify background elements in missions
This adds Lua API methods for getting suns and bitaps by index, as well as modifying their scale and position. This removes the need to completely add and remove a background element that only needs to be modified.
* big pruning of (int) casts
* Add control_info driver sources
* Properly deal with cockpits and their 'objnum's
* Add driven animation sets to weapons and cockpits
* enumify objnums
Several handle types in the scripting API used inheritance where composition would be more appropriate. This refactors those types, as well as removing the various handle types that were just aliases for `model_h`. These are just the C++-side types; all the Lua types remain as-is.
This also refactors `sound_h` to move the previous `isSoundValid` to `isValid` so that `ade_set_args` will work properly for sounds with the `Lua_API_returns_nil_instead_of_invalid_object` flag. The subclassing from `sound_entry_h` was removed and the "full validity check" was moved to `isValidWithEntry`. The Lua side remains unaffected, but additional documentation was added to clarify the usage.
Follow-up to #6009 and prerequisite to #6006 due to the `isValid` refactor for `sound_h`.
There was confusion in the lighting code between light indexes and sun indexes. These are usually the same, but not always. This makes several changes to fix light/sun handling.
1. Clarify the distinction between lights and suns and add a `sun_index` field
2. Add a flags field and assign the `dual_cone` boolean to it, as well as a new glare flag
3. Determine light glare by checking the light flag, not the sun (which never worked in the first place as the `stars_sun_has_glare` function checked bitmaps rather than suns)
* 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
There was an extra check during ship class parsing that prevented a ship class's type from being set if it had been set already. This dates back to commit 5f3a6ec7 and was added as a parsing safeguard rather than as part of any modular table checks. Since the parsing has changed, this extra check is no longer applicable. Removing the check allows a ship class with a different type to be created using an existing ship class as a template.
This rather insidious FRED bug was all down to an improper check for the current ship. It is possible for multiple objects of different types to be selected at the same time. If, for example, a waypoint and ship are selected, and the waypoint was selected first, the waypoint will be what `cur_object_index` refers to. Since the ship is the one and only ship selected, it will be what `single_ship` refers to. Therefore, to avoid flagging its own ship name as a duplicate, the loop should exclude the single ship, not the current object.
The bug can be reliably triggered by selecting a waypoint, then adding a ship to the selection, then switching the focus to another application and back to FRED. This finally squashes the bug.
This improves the ability of Lua to check for ship arrival status:
1. Deprecates the `isWarpingIn` function, which can be misleading, and replaces it with the equivalent `isWarpingStage1`
2. Adds an `isWarpingStage2` function to fill a gap in functionality
3. Adds an `isArrivingWarp` function (complementing the existing `isDepartingWarp` function) to cover both stage 1 and stage 2
In #2464, a somewhat hard-to-understand equation involving taking the modulo of a random number was replaced with a function that would do those calculations instead. The problem is that the function performed the *entire* formula, while the code it replaced was only operating on the *difference* between the two numbers. Fortunately, this is as easy to fix as changing a `+=` into just an `=`.
There were a few instances of `Random::next()` being called without ensuring its arguments couldn't trip an assertion. This should hopefully catch them all.
Before this commit, `IFF_COLOR_SELECTION`, `IFF_COLOR_MESSAGE`, and `IFF_COLOR_TAGGED` were hardcoded indices into the `Iff_colors` vector. This could cause problems if any of these three colors were set to the same RGB values (since `iff_init_color()` doesn't create a new entry if the color already exists in the vector), and if a modular table tried to change any of these colors nothing would happen (since it would just create a new entry in `Iff_colors` without doing anything to the hardcoded indices).
This commit instead changes the `#define`s into `extern int`s, and assigns the return value of `iff_init_color()` to those global variables upon parsing the special color values, meaning that any combination of the three can be set to the same color without causing issues, and modular tables can actually modify them.
Potential clutter from unused values in the `Iff_colors` vector is basically unchanged (technically slightly worse if a modular table overrides any of these special colors with a color that doesn't already exist in the vector), but should maybe be looked at in the future.
The general expectation is that model filenames can be specified as 'none' or '<none>' for no model, but as discovered by no tea, this was not consistent across the code base. For example, `$Model File: none` was handled as expected but `$External Model File: none` was not. This PR makes the handling consistent for all ship, weapon, and shockwave POF files, and also adds some extra checks when models are loaded.
1. Fix the item ID indexing on the popup submenus and make sure they correspond with the ship dropdown menu
2. Remove the "player start" popup menu option as it has very limited utility and was already removed in qtFRED
3. Reduce a bunch of casts by using more appropriate popup menu types
4. Actually place an object in the mission when one is chosen from the popup menu
Also:
1. Remove the `Default_player_model` variable as its use is redundant
2. Remove unused arguments of `create_player()`
The result of this special parsing should produce a mod string identical
to the string passed on the command line with the following exceptions:
directory name case, directory separators
Should address the following:
- no fundamental difference in modlist compared to Windows
- no errors or warnings that are not produced on Windows
- do not remove mods from list if missing
- verify mod directory is accessible and actually a directory
- do minimum amount of work to see if mod directory is valid
- fix bug with trainling slashes
Old Volition bug where the original directory is pushed onto a stack
before the chdir() call. If that call fails then the stack is left with
a used entry that won't be removed until restart and can cause the stack
to fill up. Now it's added only if the chdir() call succeeds.
Also take the opportunity to make Cfile_stack dynamic.
Change the casts used in the convenience #defines in floating.h. Since these #defines are used pretty widely, this should reduce the count of C-style casts in the codebase by quite a bit.
Also change the casts in floating.cpp while we're at it, and remove some obsolete or unused code.
Make sure all medal fields are properly assigned. In particular, if a modular -mdl.tbm is parsed, don't overwrite information from the base medals.tbl. Fixes a bug reported in Discord.
This fixes command briefing data apparently disappearing. The ui was not being properly initialized because model_changed was being called before the ui was initialized, leading to default values.
This also fixes a few other minor issues.
In #5649 / b6c0e8b, the ship registry was updated to take ship death rolls into account. There was one small wrinkle that it did not account for, however: SEXP operators that return numeric values had previously (i.e. before the introduction of the ship registry) checked the mission log for ship destruction, but after #5649 the EXITED status was not set until after the ship had completely exploded, resulting in certain SEXPs having their conditions slightly modified. The equivalent of checking the mission log for ship destruction is now checking the ship status for DEATH_ROLL, so it is necessary to make that change for the numeric SEXPs to behave as they did before.
The motivating result for all this is to fix SEXPs like `hits-left` firing after a ship has been destroyed but before it has finished exploding. This can be seen by loading the first non-training mission of FSPort and comparing the messages that are sent if you use cheats to kill Alpha 2.
SEXP helps should let the FREDder know whether a given ship argument
needs to be already in-mission for the SEXPression to operate. Update
the helps to include (ship needs to be in-mission) or (ship does not
need to be in-mission) or other relevant helpful information.
Check the filenames used to initialize HUD gauges and mark the gauge as hi-res if the filename starts with 2_. Also add a script method to return this value.
Additionally, make accessor methods `const`.
Since its creation, the `is-in-mission` sexp operator has only checked for ships. But mission designers might assume this also works for wings, leading to a situation where the sexp always returns false because no ship can have the same name as a wing. Fortunately wing functionality can be added to this sexp without affecting ship functionality.
This fixes a few items that were revealed in the course of Dark Visor's SEXP documentation PR. The EXITED status should return NAN_FOREVER, not just NAN. The CANT_EVAL value is never returned from the sexp on account of ship status, due to the preceding check, and is not an appropriate return value anyway; so that is removed. Finally, for a ship that can't move, the NAN return value is better than CANT_EVAL, since it represents the numeric situation more accurately and can also be checked by `is-nan`.
This adds a new field to particle effects so that particle rotation can be configured on a per-type basis, not just on a blanket basis. Implements #5941.
As reported by Trivial Psychic, if the number of subsystems exceeds the max as the result of a modular table, the error message was very misleading. This fixes the error message and also makes it report the correct number of parsed subsystems.
`ai_get_weapon` is not guaranteed to return a valid `wip`, so check for that here. This should now cover all uses of `ai_get_weapon` in the codebase.
Fixes an Event Horizon crash reported in Discord. Follow-up to #5842, commit 8dbe0e7.
Apple Silicon Macs require that all code is signed in order to run. Our builds
are partially signed due to the SDL framework already being signed, so it is
seen as broken. To fix that we need to codesign all the rest of the necessary
files with an ad-hoc signature in order to allow the builds to work properly.
This is a new method of ensuring that OPF_POSITIVE numbers are positive. It works for all numeric arguments, including variables and literals, and caches the status of the node to avoid lookups for every negative number on every frame. Tested on both operator and non-operator cases.
Follow-up to #5915.
Operators that specify OPF_POSITIVE should be guaranteed to get positive numbers. This code was previously disabled for performance reasons, but following the contract of the SEXP system is more important. A future PR will improve the performance of the functions used here.
Also, the `num-players` operator takes no arguments, so fix that.
In consultation with @BMagnu, code that validates data in the POF file itself should happen in `read_model_file_no_subsys`, as virtual POFs rely on their source files having correct data. I've added comments and slightly rearranged things to make this clearer, and also moved the new code from `read_and_process_model_file`. Additionally, I fixed two bugs by changing `parent > pm->n_models` to `parent >= pm->n_models` and adding a newline to the `nprintf`.
After getting the main state from the Lua registry, this function had
two Lua thread values on its Lua stack but we only removed one which
lead to a value being left on the stack.
Why did this not blow up before? Because undefined behavior.
The only place where this was called was when creating a Lua reference
value where luaL_ref is called in the same expression (see
UniqueLuaReference::create). The evaluation order of the parameters for
the make_shared call is not defined by the standard and for some reason
all major compilers (except clang) choose to execute the luaL_ref call
before the getMainThread call.
For those compilers, everything is fine. We have some extra values on
the Lua stack but that gets cleaned up after the API function finishes.
However, clang first evaluates the getMainThread which leaves an extra
Lua thread on the Lua stack. The luaL_ref call then references this
thread value instead of the intended value. In the concrete case, this
meant that LuaFunction saw that the reference points to a thread and
rightfully threw an exception.
This fixes#5904.
Use a single canonical `frametime` value for all HUD rendering, in both `hud_render_preprocess` and `hud_render_all`. Previously, certain functions called through `hud_render_preprocess` were using the full frametime, rather than the half frametime needed for VR when the HUD is rendered twice.
Fixes#5882.
Use a simpler, more robust, and more correct method of sharing the fire direction among beams: replicate the actual beam vector for all firing points. This further cleans up and simplifies the beam firing code and also clarifies some vector math.
1. make `check_ok_to_fire` return a boolean (like `check_los`)
2. make `check_ok_to_fire` and `check_los` both use a position argument since we don't need the whole turret
3. remove the redundant position prediction code from `ship_get_global_turret_gun_info` (since that needs to be a "pure" function) while making sure "share fire direction" still works
4. skip calculation of the vector in `ship_get_global_turret_gun_info` if we don't need it
5. move the position prediction code out of `aifft_rotate_turret` and into its own function
6. prune some gun position calculation calls since in most cases one will suffice
7. fix position "jitter" with weapon subsystem damage in missions that use gravity
8. `model_rotate_gun` now uses a nullptr position for a reset instead of an extra boolean argument
9. use a more efficient method to calculate gun barrel length
10. a couple variable name changes for clarity
1. Allow a `+` to appear in front of numbers, just as with `-`
2. Check for `.` and `,` within numbers to give a less misleading error message than "not a number"
3. The old number hack inadvertently skipped numeric literals, so specifically check for those
There are several SEXP argument types that themselves encompass multiple argument types: for example, ships and wings. This could be misleading when there is an error message displayed. So, this updates the error codes to explicitly cover all of the possibilities.
By using app image and switching to Checkout V1.
Also removes Vulkan SDK install, since it seems to be taken care of by the app image or is disabled. I can't figure it out from the app images.
The requirement for delayed event status checks to be strictly greater than the event fired timestamp (see commit eed50619ca / PR #5267) means that `is-event-true-delay 0` will not work in debriefings if the event becomes true and the debriefing SEXPs are evaluated on the exact same timestamp. Normally this is not a problem, but one important exception is the `end-mission` operator which instantly sends the player to debriefing.
This timestamp behavior is working as designed and should be consistent as long as the `end-mission` operator has been around (I've verified it as far back as 3.7.4). But it does lead to inconvenient situations where the event that called `end-mission` cannot be evaluated by the debriefing. This makes it slightly more complicated to plan debriefing stages based on these events.
Therefore, it makes sense to add an exception to the event status function to ignore the delay if the evaluation is not in-mission. This is consistent with evaluating events that *never* fired and also satisfies the principle of least astonishment for mission designers.
This also adds relevant documentation to the event and goal status operators.
# Make sure the source and binary directory are not the sample
@@ -47,11 +47,6 @@ endif()
PROJECT(FS2_OpenLANGUAGES${FSO_LANGUAGES})
IF(CMAKE_CROSSCOMPILING)
SET(IMPORT_EXE_DIR"IMPORT_EXE_DIR-NOTFOUND"CACHEFILEPATH"Required for a cross compiling build, point to binary directory of a cmake build for the real OS")
Deprecations are a mechanism in FSO where a certain feature or aspect of the engine has changed or is no longer supported. Since this would normally break existing mods we have the mod table feature "[tt]$Target Version:[/tt]" with which a mod can specify what version of FSO it was developed with. The features listed above will be removed or changed when the target version of a mod is at least the version released in this post.
Deprecations are a mechanism in FSO where a certain feature or aspect of the engine has changed or is no longer supported. Since this would normally break existing mods, we have the mod table feature "[tt]$Target Version:[/tt]" with which a mod can specify what version of FSO it was developed with. Any features listed under Deprecations will be removed or changed when the target version of a mod is at least the version released in this post.
[b]All platforms: [/b] For every day use, we recommend [url=https://www.hard-light.net/forums/index.php?topic=94068.0]Knossos[/url], an integrated solution for downloading and launching mods.
[b]All platforms: [/b] For every day use, we recommend [url=https://knossosnet.github.io/Knossos-Release-Page/]Knossos.NET[/url], an integrated solution for downloading and launching mods.
[hidden=Alternative Launchers]
Cross-platform: [url=https://www.hard-light.net/forums/index.php?topic=89162]wxLauncher 0.12.x Test Build[/url] (ongoing project for a unified launcher, you should upgrade to the latest RC/test build if you have not yet)
Cross-platform: [url=https://www.hard-light.net/forums/index.php?topic=89162]wxLauncher 0.12.x Test Build[/url] (legacy project for a unified launcher)
[b]Important:[/b] For best compatibility with FSO 3.8 and later you should use at least wxLauncher 0.12.
Windows: [url=http://scp.fsmods.net/builds/Launcher55g.zip]Launcher 5.5g[/url] ([url=https://scp.indiegames.us/builds/Launcher55g.zip]Mirror[/url]) ([url=https://www.mediafire.com/?wdvzn7hhhzh418m]Mirror[/url]) Not compatible with Windows 8+, use wxLauncher above
[b]What are those SSE, SSE2 and AVX builds I keep seeing everywhere?[/b]
[url=https://www.hard-light.net/forums/index.php?topic=65628.0]Your answer is in this topic.[/url]
Don't want to deal with that? Use [url=https://www.hard-light.net/forums/index.php?topic=94068.0]Knossos[/url] and it will download the best build specifically for your PC!
Don't want to deal with that? Use [url=https://knossosnet.github.io/Knossos-Release-Page/]Knossos.NET[/url] and it will download the best build specifically for your PC!
These builds use a mechanism called [url=https://appimage.org/]AppImage[/url] which should allow these builds to run on most Linux distributions. However, we recommend that you compile your own builds which will result in less issues.
Alternatively, if there is a package in your software repository then you should use that. If you are the maintainer of such a package for a distribution then let us know and we will include that here.
SET(MSVC_SIMD_INSTRUCTIONS"${MSVC_DETECTED_SIMD_INSTRUCTIONS}"CACHEFILEPATH"The SIMD instructions which will be used, possible values are ${POSSIBLE_INSTUCTION_SETS}")
set(FORCED_NATIVE_SIMD_INSTRUCTIONSONCACHEBOOL"Override instruction set detection and compile with the maximum possible instructions for the current system.")
@@ -96,6 +96,7 @@ extern const int Num_ai_flag_names;
#define MAX_ENEMY_DISTANCE 2500.0f // Maximum distance from which a ship will pursue an enemy.
#define MAX_AI_GOALS 5
#define AI_ACTIVE_GOAL_NONE -1
#define AI_ACTIVE_GOAL_DYNAMIC 999
typedefstructai_class{
@@ -276,8 +277,8 @@ typedef struct ai_info {
intai_class;// Class. Might be override of default.
// Probably become obsolete, to be replaced by path_start, path_cur, etc.
waypoint_list*wp_list;// waypoint list being followed
intwp_index;// waypoint index in list
intwp_list_index;// index of waypoint list being followed
intwp_index;// index of waypoint in list
intwp_flags;// waypoint flags, see WPF_xxxx
intwaypoint_speed_cap;// -1 no cap, otherwise cap - changed to int by Goober5000
@@ -317,7 +318,7 @@ typedef struct ai_info {
//Unlike the predicted position stuff, also takes into account velocity
//Only used against small ships
fixnext_aim_pos_time;
vec3dlast_aim_enemy_pos;
vec3dlast_aim_enemy_pos;// Normally this is the position of the enemy a turret is targeting but in the F3 Lab, this is used to pass raw target coordinates to the turret firing methods.
vec3dlast_aim_enemy_vel;
ai_goalgoals[MAX_AI_GOALS];
@@ -329,7 +330,7 @@ typedef struct ai_info {
floattime_enemy_near;// SUSHI: amount of time enemy continuously "near" the player
fixlast_attack_time;// Missiontime of last time this ship attacked its enemy.
fixlast_hit_time;// Missiontime of last time this ship was hit by anyone.
intlast_hit_quadrant;// Shield section of last hit.
intdanger_shield_quadrant;// Shield section AI will prefer to prioritize for recharging, it if possible.
fixlast_hit_target_time;// Missiontime of last time this ship successfully hit target.
inthitter_objnum;// Object index of ship that hit this ship last time.
inthitter_signature;// Signature of hitter. Prevents stupidity if hitter gets killed.
@@ -484,7 +485,7 @@ typedef struct {
#define SUBSYS_PATH_DIST 500.0f
// Friendly damage defines
#define MAX_BURST_DAMAGE 20 // max damage that can be done in BURST_DURATION
#define MAX_BURST_DAMAGE 20.0f// max damage that can be done in BURST_DURATION
#define BURST_DURATION 500 // decay time over which Player->damage_this_burst falls from MAX_BURST_DAMAGE to 0
externintMission_all_attack;// !0 means all teams attack all teams.
@@ -533,8 +534,8 @@ extern void ai_ignore_wing(object *ignorer, int wingnum);
Unload_primaries,// Fire primaries as fast as possible!
Trying_unsuccessfully_to_warp,// Trying to warp, but can't warp at the moment
Free_afterburner_use,// Use afterburners while following waypoints or flying towards objects
Waypoints_no_formation,// wont get into formation when running waypoints as part of a wing
NUM_VALUES
};
@@ -41,7 +43,7 @@ namespace AI {
Dockee_index_valid,// when set, index field for dockee is valid
Goal_on_hold,// when set, this goal cannot currently be satisfied, although it could be in the future
Subsys_needs_fixup,// when set, the subsystem index (for a destroy subsystem goal) is invalid and must be gotten from the subsys name stored in docker.name field!!
Goal_override,// paired with AIG_TYPE_DYNAMIC to mean this goal overrides any other goal
Goal_override,// paired with ai_goal_type::DYNAMIC to mean this goal overrides any other goal
Purge,// purge this goal next time we process
Goals_purged,// this goal has already caused other goals to get purged
Depart_sound_played,// Goober5000 - replacement for AL's hack ;)
@@ -99,6 +101,10 @@ namespace AI {
Fix_heat_seeker_stealth_bug,
Fix_linked_primary_bug,
Fix_ramming_stationary_targets_bug,
Fix_avoid_shockwave_bugs,// a) waiting until a homing weapon actually homes before evading;
// b) picking the correct expected impact position for capships;
// c) not clearing shockwave_object for ships;
// d) checking the explosion damage of the correct ship
if(!(En_objp->flags[Object::Object_Flags::Protected])||((aip->goals[0].ai_mode&(AI_GOAL_DISABLE_SHIP|AI_GOAL_DISABLE_SHIP_TACTICAL|AI_GOAL_DISARM_SHIP|AI_GOAL_DISARM_SHIP_TACTICAL))&&swip->wi_flags[Weapon::Info_Flags::Puncture])){//override lockdown on protected ships when using anti subsystem weapons - Valathil
if(!(En_objp->flags[Object::Object_Flags::Protected])||(ai_goal_is_disable_or_disarm(aip->goals[0].ai_mode)&&swip->wi_flags[Weapon::Info_Flags::Puncture])){//override lockdown on protected ships when using anti subsystem weapons - Valathil
// If ship is protected and very low on hits, don't fire missiles.
@@ -135,22 +141,22 @@ const char *Ai_goal_text(int goal, int submode)
returnXSTR("rearm ",484);
caseAI_GOAL_FLY_TO_SHIP:
returnXSTR("rendezvous with ",1597);
caseAI_GOAL_LUA:
caseAI_GOAL_LUA:{
automode=ai_lua_find_mode(submode);
if(mode==nullptr)
returnnullptr;
returnmode->hudText;
}
// Avoid compiler warning
returnnullptr;
default:
returnnullptr;
}
}
/**
* Reset all fields to their uninitialized defaults. But if this is being called before adding a new goal, the function will set the correct signature and time.
* Similarly the added mode, submode, and type can be assigned.
Assertion(asteroid_info_index<(int)Asteroid_info.size(),"Command to load asteroid at index %i, but only %i asteroids exist",asteroid_info_index,(int)Asteroid_info.size());
Assertion(asteroid_subtype<NUM_ASTEROID_POFS,"Command to load asteroid pof %i, but only %i pofs are allowed",asteroid_subtype,NUM_ASTEROID_POFS);
Assertion(!Asteroid_field.field_asteroid_type.empty(),"maybe_throw_asteroid() called while field_asteroid_type.size was 0; this should never happen, get a coder!");
model_render_queue(&render_info,scene,Asteroid_info[asp->asteroid_type].model_num[asp->asteroid_subtype],&obj->orient,&obj->pos);// Replace MR_NORMAL with 0x07 for big yellow blobs
model_render_queue(&render_info,scene,Asteroid_info[asp->asteroid_type].subtypes[asp->asteroid_subtype].model_number,&obj->orient,&obj->pos);// Replace MR_NORMAL with 0x07 for big yellow blobs
Warning(LOCATION,"Invalid fireball type %i specified for an asteroid; only "SIZE_T_ARG" fireball types are defined.",fireball_type,Fireball_info.size());
std::pair<constchar*,int>{"Cockpit Field Of View",1840},
std::pair<constchar*,int>{"The vertical field of view for cockpit rendering. Only works if cockpits are active and cockpit FOV toggle is turned on.",1841})
@@ -826,7 +827,8 @@ static void check_file_shadows(const int root_index __UNUSED, const int pathtype
}
// this log message occurs in the middle of an existing line, hence the extra new lines
mprintf(("\nWARNING! A %sfile being indexed may be shadowed by an existing file!\n New:\n %s\n Existing:\n %s\n",
// critical files and files in same root are always logged, files in different root are behind a filter
nprintf(((critical||!root->path.compare(r->path))?"General":"CFileSystem","\nWARNING! A %sfile being indexed may be shadowed by an existing file!\n New:\n %s\n Existing:\n %s\n",
{"-nonormal","Disable normal maps",true,EASY_DEFAULT|EASY_HI_MEM_OFF,EASY_ALL_ON|EASY_HI_MEM_ON,"Graphics","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nonormal"},
{"-emissive_light","Enable emissive light from ships",true,0,EASY_DEFAULT,"Graphics","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-emissive_light"},
{"-3dshockwave","Enable 3D shockwaves",true,EASY_ALL_ON|EASY_HI_MEM_ON,EASY_DEFAULT|EASY_HI_MEM_OFF,"Graphics","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-3dshockwave"},
{"-capture_mouse","Capture the mouse within the window",true,0,EASY_DEFAULT,"Gameplay","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-capture_mouse",},
{"-stretch_menu","Stretch interface to fill screen",true,0,EASY_DEFAULT,"Gameplay","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-stretch_menu",},
{"-noscalevid","Disable scale-to-window for movies",true,0,EASY_DEFAULT,"Gameplay","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noscalevid",},
{"-3dwarp","Enable 3D warp",true,0,EASY_DEFAULT,"Gameplay","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-3dwarp",},
{"-warp_flash","Enable flash upon warp",true,0,EASY_DEFAULT,"Gameplay","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-warp_flash",},
{"-no_unfocused_pause","Don't pause if the window isn't focused",true,0,EASY_DEFAULT,"Gameplay","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_unfocused_pause",},
{"-orig_speedx_range","Restrict speedup/slowdown (1x to 4x)",true,0,EASY_DEFAULT,"Gameplay","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-orig_speedx_range",},
//flag launcher text FSO on_flags off_flags category reference URL
{"-nosound","Disable all sound",false,0,EASY_DEFAULT,"Audio","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nosound",},
@@ -241,6 +237,8 @@ Flag exe_params[] =
{"-prefer_ipv6","Prefer IPv6 DNS lookups",true,0,EASY_DEFAULT,"Troubleshoot","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-prefer_ipv6",},
{"-log_multi_packet","Log multi packet types ",true,0,EASY_DEFAULT,"Troubleshoot","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-log_multi_packet",},
{"-no_bsp_align","Disable pof BSP data alignment",true,0,EASY_DEFAULT,"Troubleshoot","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_bsp_align",},
{"-no_large_shaders","Split large shader into smaller shaders",true,0,EASY_DEFAULT,"Troubleshoot","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_large_shaders",},
#ifdef WIN32
{"-fix_registry","Use a different registry path",true,0,EASY_DEFAULT,"Troubleshoot","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fix_registry",},
#endif
@@ -263,6 +261,7 @@ Flag exe_params[] =
{"-output_sexps","Output SEXPs to sexps.html",true,0,EASY_DEFAULT,"Dev Tool","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-output_sexps",},
{"-output_scripting","Output scripting to scripting.html",true,0,EASY_DEFAULT,"Dev Tool","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-output_scripting",},
{"-output_script_json","Output scripting doc to scripting.json",true,0,EASY_DEFAULT,"Dev Tool","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-output_script_json",},
{"-output_script_lua","Output scripting doc to scripting.lua",true,0,EASY_DEFAULT,"Dev Tool","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-output_script_luastub",},
{"-controlconfig_tbl","Save control presets to table",true,0,EASY_DEFAULT,"Dev Tool","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-controlconfig_tbl",},
{"-save_render_target","Save render targets to file",true,0,EASY_DEFAULT,"Dev Tool","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-save_render_target",},
{"-verify_vps","Spew VP CRCs to vp_crcs.txt",true,0,EASY_DEFAULT,"Dev Tool","http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-verify_vps",},
@@ -317,7 +316,6 @@ int Cmdline_cd_check = 1;
intCmdline_closed_game=0;
intCmdline_freespace_no_music=0;
intCmdline_freespace_no_sound=0;
intCmdline_gimme_all_medals=0;
intCmdline_mouse_coords=0;
intCmdline_multi_log=0;
intCmdline_multi_stream_chat_to_file=0;
@@ -341,15 +339,12 @@ cmdline_parm emissive_power_arg("-emissive", "Multiplies the brightness of all a
cmdline_parmemissive_arg("-emissive_light","Enable emissive light from ships",AT_NONE);// semi-deprecated but still functional
"Sets the joystick deadzone. Integer value from 0 to 100 as a percentage of the joystick's range (100% would make the stick do nothing).Disablesdeadzonesliderinthein-gameOptionsmenu.", AT_INT);//Cmdline_deadzone
intCmdline_ship_choice_3d=0;
intCmdline_weapon_choice_3d=0;
intCmdline_autopilot_interruptable=1;
intCmdline_stretch_menu=0;
boolCmdline_stretch_menu=false;
boolCmdline_capture_mouse=false;
intCmdline_no_screenshake=0;
intCmdline_deadzone=-1;
boolCmdline_enable_vr=false;
@@ -433,8 +418,10 @@ int Cmdline_no_enhanced_sound = 0;
// MOD related
cmdline_parmmod_arg("-mod","List of folders to overwrite/add-to the default data",AT_STRING,true);// Cmdline_mod -- DTP modsupport
cmdline_parmcampaign_arg("-campaign","Set current campaign",AT_STRING);// Cmdline_campaign
char*Cmdline_mod=NULL;//DTP for mod argument
char*Cmdline_campaign=nullptr;// for campaign argument
// Multiplayer/Network related
cmdline_parmalmission_arg("-almission","Autoload multiplayer mission",AT_STRING);// Cmdline_almission -- DTP for autoload Multi mission
"Confirm new custom preset name.\n\nThe name must not be empty.\n\n Press [Enter] to accept, [Esc] to "
"abort to config menu.",
XSTR("Confirm new custom preset name.\n\nThe name must not be empty or a default preset.\n\n Press [Enter] to accept, [Esc] to abort to config menu.",1867),
//English scancodes are still needed eclusively for the scripting API, as we need to give generic and stable scan code names to the API that are neither translated nor localized to keyboard layout.
//All the following computations are just required if we have a stepcoloralpha that is non-zero.
if(stepcolor_alpha > 0.01)
{
@@ -127,10 +131,10 @@ void main()
//Diffuse
#ifdef NOISE
//Mix the actual nebula color with the noise color depending on the product of the noise channels multiplied with intensity, smooth-clamped from 0 to 1
// do not draw if a mod has disabled this control --wookieejedi
if(ci->disabled){
return;
}
buf[0]=0;
strcpy_s(buf,ci->first.textify().c_str());
Loaded 100 of 1073 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.