180 Commits
Author SHA1 Message Date
Goober5000andClaude Opus 5 e2be023f84 Replace the Cockpit_active global with computed predicates
Cockpit_active was latched inside ship_render_player_ship(), which only
runs when Viewer_obj is non-null.  External, chase, warp-chase, topdown,
free-camera and dead views all null Viewer_obj, so the flag froze at its
last cockpit-view value and cockpitinactive HUD gauges vanished.  It was
also read before being written each frame (by the show-ship check and the
shadow helpers), so those decisions lagged a frame on any transition.

Replace it with three functions computed on demand:
- ship_cockpit_enabled(sip): the ship has a cockpit model and cockpits
  aren't disabled; used by the Show_ship_only_if_cockpits_enabled checks
- ship_render_player_cockpit(sip): the above, outside topdown view;
  replaces three duplicated copies of that expression
- ship_render_player_cockpit_active(): whether the viewer's cockpit is
  being rendered this frame; used by the HUD cockpit-view-choice checks

With the predicate correct, the VM_CHASE special cases added for #4804
are no longer needed and are removed.  In chase view, cockpitinactive
gauges now also respect pop-up state, No_ets, and setRenderOverride,
which the early return in HudGauge::canRender() used to bypass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-09-11 23:39:05 -04:00
Goober5000 1ea98b19d5 tiny tweak fix to the comm menu
Reset the selected item when we open a new menu.  This keeps the display state and internal state in sync if the player mixes arrow presses and number presses.  Follow-up to #7688.
2026-08-16 15:10:35 -04:00
wookieejedi 4a1f16c453 update to new version 2026-08-16 13:06:10 -04:00
wookieejedi 0f3f80b03a Merge branch 'master' into fix-skip-hidden-menu-items 2026-08-16 08:56:40 -04:00
Kestrellius 1967daffd3 Vectorize MsgItems (#7687)
Convert MsgItems from an array to a vector, and remove the associated limit value and counter.

* vectorize msgitems

* appeasement

* leave me alone clang

* remove optional

* cleanup

* changes requested

* clang

* clang what is WRONG with you

* feedback

* remove flag in .h
2026-08-16 02:04:50 +00:00
wookieejedi 23f4a1ca1f Fix COMMS_MENU_SELECT control usage with 'Hide Rearm/Repair items'
The game settings flag '$Hide main Rearm/Repair items in Comms Gauge:' hides the 'Rearm and Repair' lines in the HUD Comms menu from appearing, which is useful for mods that do not have repair ships and thus those lines confuse players. Unfortunately, the newer `COMMS_MENU_SELECT` control bindings do not properly account for hidden menu items, so using those controls on a comms menu with 'Rearm and Repair' hidden means the selection index gets off and also confuses the player.

This PR fixes that by allowing `hud_squadmsg_selection_move_down()` and `hud_squadmsg_selection_move_up()` to skip hidden menu items. Tested and works as expected.

For folks using the COMMS_MENU_SELECT controls, there is also a current UI confusion when the comms menu is first brought up because the first item is selected, but the `Display_selector` does not show. Thus, players are unsure what item is actively selected even though one is actively selected. In the original comms menu select PR this was set to on by default, but then switched to off by default by a different developer a bit later. This choice is especially useful for mods that have many players with gamepads such as Event Horizon. Alternatively, mods that already have many number keys utilized for other gameplay aspects seem to prefer to keep the comms menu visuals as is and only show the selection if the player uses those keys. Given there is clearly arguments for both reasons, ideally modders should be able to choose how it displays for their own mods (always or off for the first pop-up of the Comms menu).  Thus, this PR adds that as a cleanup game option, too. This also was tested and works as expected.
2026-08-06 11:06:41 -04:00
The Force da05081405 Fix C4709 Warnings In modern VS (#7576)
* Fix C4709 Warnings on latest VS

* more

* suppress false positive

* Switch to using any/none_of

* Address Feedback

* Fix Line endings?

* Fix commits and strip out flag_combinator

* more fixes

* nolint
2026-07-26 14:33:00 +01:00
Goober5000 4d2d4944ce fix "mesage" (#7569)
The CMake misspelling is a bug; the others are cosmetic; but might as well fix all of them.

Small follow-up to #7029.
2026-07-07 01:38:44 +00:00
Goober5000 7545e5d035 make the reinforcements collection dynamic
As requested by a FREDder who has a plausible situation where more than 32 reinforcements might be handy. :)
2026-05-26 10:55:05 -04:00
Goober5000 70c4010389 add wing display names (#7429)
* add wing display names

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

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

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

Addresses #7189 and the last request from #1730.

* add help text from #7234
2026-05-20 15:16:08 -04:00
Mike Nelson f02c01a81e fix gauges not respecting table flags (#7426) 2026-05-08 12:58:57 -04:00
Goober5000andClaude Opus 4.6 3f85d6172a use std::move() for local variables that are copied but not reused (#7308)
* use std::move() for local variables that are copied but not reused

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

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

* clang: use std::make_shared

* clang: use std::make_unique

* address feedback

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-07 14:40:38 +09:00
Goober5000 306f34a574 update force_fit_string and bounds in calling functions (#7161)
Rewrite `force_fit_string` to be more robust and to remove the potential for memory access violations.  Also audit all of the length parameters in the calling functions - some of them were the buffer size, not the length.  This should fix the mysterious crash in the mission log screen.
2025-12-25 08:08:46 +09:00
wookieejedi f95ae0b1bd Prevent Potential Memory Problems with squadmsg hook function (#6801)
* Prevent Potential Memory Problems with squadmsg hook function

Within `hud_squadmsg_run_order_issued_hook` it is possible for the calling code to pass `nullptr` as the target parameter, which would cause memory problems with the several instances of `Objects[target->objnum]`. This PR mitigates that potential while testing of  `hud_squadmsg_run_order_issued_hook` still works as expected.

* add more safety
2025-06-30 12:14:28 -04:00
Goober5000 329974b4bf a few refinements to the new comm node selection feature
1. Don't display the selection arrows until the selection is actually moved, to avoid interfering with the standard selection feature
2. Use static variables and the new `TIMESTAMP` data type
3. Minor cleanup

Follow-up to #6736.
2025-06-29 00:05:48 -04:00
John Fernandez a9664ff22f Merge pull request #6752 from Goober5000/stay_near_target_fix
fix STAY_NEAR_TARGET_ITEM
2025-06-19 19:44:55 -04:00
wookieejedi 26477276da Allow modders to tune Comms Styling (#6776)
This PR adds two new localization strings, which allow modders to change how the numbers in the comms menu are displayed, and it incorporates styling for the comms selection controls from #6736, too.

Tested and works as expected.
2025-06-17 22:58:45 -04:00
Mateusz Uberna 5864ec4e7e Comms menu controls (#6736)
* Added new keybinds, keycontrol handlers,  hudsquadmsg methods for alternate communication menu control scheme

* .gitignore update. CMake in VStudio places builds in [Oo]ut/ folder by default

* Added support for menu pages

* Small formatting cleanup

* code cleanup

* removed unecessary variable

* Updates after code review

* Updated comments

* XSTR_SIZE correction
2025-06-14 13:27:01 +00:00
Goober5000 939d6a50c2 additional fix for STAY_NEAR_TARGET_ITEM
When issuing the stay-near-target order via hud squad message, default to a distance of 300, the same as the sexp.
2025-06-07 00:09:36 -04:00
Goober5000 3783cb0d1d fix STAY_NEAR_TARGET_ITEM
1. Allow "Stay near me" and "Stay near my target" to work even if the teams do not match
2. Allow "Stay near my target" to be issued regardless of team
3. Avoid divide-by-zero errors when running `ai_stay_near()`
2025-06-07 00:06:19 -04:00
Goober5000 ceee045b35 coverity: move instead of copy 2025-05-10 01:15:46 -04:00
Mike Nelson 1f7903fb23 add a few hud lua methods (#6692) 2025-05-08 09:33:21 -04:00
wookieejedi df445fa8a6 Wingmen and Squad Message QoL Updates (#6682)
* 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
2025-04-16 22:47:14 -04:00
wookieejedi eb60a87b28 Allow mods to hide main Rearm/Repair items in Message Gauge (#6684)
* Allow mods to hide main Rearm/Repair items in Message Gauge

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

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

Tested and works as expected.

* update comment

* update with better name

* add another clarifying comment
2025-04-14 07:22:10 -04:00
Mike Nelson 7c38273f5b Lua hooks for the comm board (#6450)
* 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
2025-04-03 00:55:20 +02:00
Mike Nelson 60777154be Hud config upgrades (#6581)
* 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
2025-03-22 22:47:38 -04:00
Mike Nelson a7754e637a Fix hud errors (#6627)
* fix weapon energy text in config mode

* fix x,y  mismatch

* fix squad message copy/paste error
2025-03-09 21:09:37 -04:00
Mike Nelson acc382d169 config rendering method for messages, talking heads, and shield gauges (#6575) 2025-03-02 08:02:09 -05:00
Goober5000 1492e9c785 smol cleanup 2025-02-04 00:34:37 -05:00
Goober5000 e7029c2ddb Merge pull request #6469 from Goober5000/vmallocator_update
some upgrades to vmallocator.h
2025-02-03 21:35:37 -05:00
Mike Nelson 5b736b1ddc Hud config framework (#6495)
* 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
2025-02-03 07:01:47 -05:00
Goober5000 133b033ea0 some upgrades to vmallocator.h
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.
2025-02-02 14:54:26 -05:00
Goober5000 8baee0470a refactor AIG_TYPE_* into enum classes 2025-01-02 14:05:21 -05:00
Goober5000 c38882a51e refactor AI_GOAL_* #defines into enums, and remove bitwise operations on them [non-FRED] 2025-01-02 14:05:21 -05:00
BMagnu 01bb406b3d Allow overriding low-level keypresses (#6174)
* 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
2024-05-31 14:53:39 +02:00
Goober5000 bf7c923020 patch hud_support_find_closest
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.
2024-05-07 01:06:15 -04:00
Goober5000 bf13ce54a8 add method for determining whether the HUD is hi-res
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`.
2024-01-29 22:07:54 -05:00
John Fernandez 0a5cf6ad9d Try the std moves suggested by Coverity
For many coverity issues
2023-11-03 14:40:04 -04:00
Mike Nelson 91c15e6f48 Player general orders (#5638) 2023-10-26 19:22:44 -04:00
Sébastien Noel f149c36b44 Fix a few typos (#5598) 2023-10-24 20:33:45 -04:00
Goober5000 883ed32796 ai-disable-ship-tactical and ai-disarm-ship-tactical (#5512)
Add "tactical" versions of disable and disarm goals which only perform the specific task without implying anything else.  The target ship is not protected and attack goals are not cleared from other ships.

There is also a new AI profiles flag to make this the default hud squad message command instead of the classic disable/disarm.
2023-10-19 07:50:49 -04:00
Goober5000 99450fa643 remove hud_squadmsg_save_keys()
Remove this function and associated items, since they are commented out and unused.
2023-05-27 13:39:47 -04:00
Goober5000 59a5d2642c add hooks for comm menu opening and closing
Implements #5420.
2023-05-26 12:51:34 -04:00
Asteroth 9be559622e dont overwrite a disallowed depart order (#5352) 2023-04-19 17:30:09 -04:00
BMagnu 522e1aa360 Restrict player order accept ship (#5341) 2023-04-18 04:39:56 +09:00
naomimyselfandi 949141c611 Message filter follow up (#5304)
* Fix intra-persona message borrowing logic

Closes #5299.

* Always assign personae for Support

Disabling the Auto_assign_personas flag had the side-effect of prohibiting support ships from ever speaking. Since a mod that wants this behavior (for whatever reason) can just not have a support persona, this commit makes an exception for them.

* Make Protect Target and Cover Me adaptive like Engage Enemy is

* Respect the allow subsitution flag
2023-04-03 08:11:46 -04:00
Naomi Coffman 91acdfbc23 Ensure variable is initialized 2023-03-20 10:58:46 -04:00
Naomi Coffman 1b5b902bdd Remove unused parameters
These were always 0, and now they're gone.
2023-03-11 18:11:56 -05:00
Naomi Coffman 39b24a5789 Add subject filters to most messages 2023-03-11 17:39:49 -05:00
Naomi Coffman 95f5839b5f Disenlongate method names 2023-03-11 11:39:06 -05:00