104 Commits
Author SHA1 Message Date
Goober5000 ef73e2572d unlimited mission titles
Some code refactoring to allow mission titles to be strings of any length.  Titles that are too long to actually display (based on string width) will be visibly truncated using `font::force_fit_string`, but the underlying title will not be affected.  Multiplayer is still subject to the 31-character length limit, so titles sent over the network will still have characters truncated.

Also removes some redundant calls to `gr_get_string_size`, since `font::force_fit_string` returns the fitted string width.
2026-05-12 11:31:20 -04:00
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 5c737a5bf9 improve campaign file extension handling (#6443)
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.
2024-12-22 22:31:58 +01:00
Goober5000 33f136dd26 follow-up to BWO crash fix
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.
2024-08-27 14:06:13 -04:00
Goober5000 20338ff28b fix the mysterious crash in BWO
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.
2024-08-25 21:56:37 -04:00
Goober5000 691fe96151 Merge branch 'master' into pilot_stats_fixes 2024-07-03 20:56:56 -04:00
Goober5000 d3d9ee3092 refine campaign failure error messages 2024-01-01 17:41:42 -05:00
John Fernandez 8affd53cf6 Remove Unused Functions
These functions have not been called from what I can tell since the source code was released.  But they did happen to trigger a clang warning, so it's time to get rid of them.
2023-10-23 07:50:29 -04:00
Goober5000 829692b7bd Merge pull request #5468 from Goober5000/5462_followup
additional cleanup from PR 5462
2023-10-22 17:10:42 -04:00
Goober5000 15daaf2633 additional cleanup from PR 5462
Some streamlining and constifying of the readyroom popup list and associated functions.

Followup to #5462.
2023-07-13 01:54:25 -04:00
MageKing17 493df37287 When playing the demo, don't try to reset if no campaign is active.
If the "Campaign Room only available in full version" popup is shown, it tries to reset `Active_campaign_index`, except that if a pilot is loaded with a missing campaign file, `Active_campaign_index` is -1. This causes an out-of-bounds array access, so let's present an alternate popup in this case (either one to select whatever the first campaign file found is, or the generic `popup_game_feature_not_in_demo()` if no campaign files are found).
2023-07-12 14:53:40 -07:00
the-maddin 439c22b528 Merge branch 'master' into qt-campaign-editor 2023-02-20 21:07:01 +01:00
BMagnu af1f0eaeca Rework Script Conditions (#4960)
* add skeleton for hook condition API

* Begin Scripting Hook refactor

* Program Hook Conditions for current new-style hooks

* Replace more hooks

* Fully transition global hooks

* Convert legacy hooks pt. 1

* Convert legacy hooks pt. 2

* Convert legacy hooks pt. 3

* Post-conversion cleanup

* restore parsing

* Add Documentation and fix parsing

* Fixup engine ingame hook adding

* Fixup engine ingame hook adding again

* Fix warnings

* Fix GCC unqualified template base lookup

* unqualified lookup v2

* Virtual Destrcutors

* Fix Clang

* Fix ship objp hook condition shadow

* Remove global hook include in ship.h

* Incorporate Feedback

* Incorporate Feedback 2

* Add revision to inline version specififer
2022-12-14 03:51:27 +09:00
Goober5000 98a3c64cc8 fix campaign loading in FRED
Load campaigns using the full path provided by the user, not just from the configured mod paths.

Also tweaks initialization based on the campaign having already been cleared in `mission_campaign_clear()`.
2022-11-15 20:40:33 -05:00
Adam Leach 0eb5197ecd Fixes retail UI crash when campaign missions are selected in simulator 2022-09-15 17:35:13 +01:00
MjnMixael ff55a39dd4 Scripting functions required for SCPUI conversion of all four Tech Room UIs (#4591)
* Documentation (+6 squashed commit)

Squashed commit:

[ea8550b54] Resolve errors

[9ab0a576d] Add way to count number of elements in the arrays

[eb74146cc] Correct this boolean check

[60fbc6008] Missed one

[78e65a4b7] Avoid naming collision

[4ea5ddead] Clean unneeded log print and compare like variables

* Adding simulator room here seems like a pretty safe option

* Scpui API to access to build the tech room cutscene list and a few methods to help playing the cutscene and return to the menu accurately

* Scpui API access for credits related data

* # This is a combination of 7 commits.

Clean unneeded log print and compare like variables

Avoid naming collision

Missed one

Correct this boolean check

Add way to count number of elements in the arrays

Resolve errors

Documentation

* Address feedback

* Address feedback

* Add virtvar isCampaignMission
2022-09-14 16:01:34 +09:00
Goober5000 7013981de5 add isActive checks for new-style script hooks
What it says on the tin.  Follow-up to #3538.  Fixes #4398.
2022-06-13 02:13:14 -04:00
the-maddin 2eb6410de8 Merge branch 'master' into qt-campaign-editor 2022-05-22 22:36:23 +02:00
Goober5000 5e436dd276 fix two bugs associated with custom tech databases
1) In commit 770fce8de5, a flag was incorrectly ported from a bit to a flagset, which caused ships not in the tech db to not be removed.
2) Perhaps due to the pilot file upgrade, campaigns which had their tech databases reset would immediately load stale techroom data from the savefile.  This change writes the savefile after the reset so that subsequent reloads will load the correct data.
2022-05-05 22:42:20 -04:00
the-maddin 0a7ff1bc1a changes jg18 v3 2022-04-29 01:28:37 +02:00
the-maddin ccf86293ce incorporate feedback 2022-03-29 00:59:59 +02:00
Goober5000 375ae25ac9 add campaign start hook
This hook will be called when a campaign is started for the first time (whether in Player Select or in the campaign room), or is reset.
2022-03-20 14:48:32 -04:00
the-maddin 5e57094f8e Merge branch 'master' into qt-campaign-editor 2021-09-19 14:27:07 +02:00
Goober5000 5e7a6ece52 log when missions are skipped due to XSTR mismatch
As a follow-up to #2343, users might wonder why their mission isn't showing up in the tech room, so log a friendly message.
2021-07-16 22:17:36 -04:00
the-maddin ae9b604f44 Merge branch 'master' into qt-campaign-editor 2021-06-29 23:31:08 +02:00
the-maddin 232eb2a099 Allow full-length paths for campaign files
so qtfred can load them fro outside the cfile tree.
2021-06-20 00:56:10 +02:00
BMagnu 6c2ebab01c Fix erroneous line break generation for non-ASCII string and high resolutions (#3439)
* Added a byte limit for line length in split function

* Fix call error

* Ádd missing limits import

* Change hardcoded values into defines

* Cleanup default argument
2021-05-24 17:38:58 -04:00
Goober5000 f3bca4384f additional case functions and checks
This refactors the tolower/toupper code to use standards-conformant logic, and also adds some helpful utility functions.  Regular tolower/toupper must be supplied a value that can be represented as `unsigned char`, but the std:: functions are a bit more robust.
2021-02-18 04:23:08 -05:00
asarium bf521f1c6b Make the campaign room API available to scripting
This makes the necessary campaign room API available to the scripting
API so that it can be implemented using libRocket. Also adds an
engine.sleep function which I needed for making my Lua debugger work
reliably.
2020-06-03 17:49:15 +02:00
Goober5000 aef4c1ba3c address feedback 2020-05-05 14:38:50 -04:00
Goober5000 5ab611a8b1 this reason is only applicable in debug builds 2020-05-05 12:08:22 -04:00
Goober5000 d6c1a3dec4 implement XSTR check as described in Mantis 2942
Certain mods provide their own tstrings.tbl, but this runs into trouble when you localize data meant for one mod using a tstrings.tbl meant for another mod.  See the Mantis ticket:
http://scp.indiegames.us/mantis/view.php?id=2942
and also the HLP post:
http://www.hard-light.net/forums/index.php?topic=85041.msg1716600#msg1716600

This PR adds an optional flag that will check the untranslated string against the "default language" translated string.  The two strings should be identical.  If they aren't, the code assumes there is a tstrings.tbl mismatch.

I modified the mission listing code to enable this check when localizing mission info (titles and descriptions), and to avoid adding the mission to the list if there is a mismatch.  Fortunately, I think mission listing is the only place where this bug is likely to happen.
2020-04-27 22:42:13 -04:00
Goober5000 bd5fef4861 actually, there is one case where we still need to reset the tech db 2019-11-28 14:40:37 -05:00
Goober5000 1b533d5c7e don't restart if we are switching to a previously finished campaign
This is a follow-up to #1450, based on feedback and preference.  Instead of always resetting campaign progress, just switch to the campaign.  The player can then explore the tech room database or the finished missions if he chooses.

This also fixes a few bugs:

1) Ever since the tech-database-reset feature was introduced in 2003 or so, the game incorrectly checked the campaign being unselected, not the campaign being selected.  This is now obsolete since neither the tech database nor the campaign progress are reset.
2) Not all campaign loading failure types were recorded in `mission_load_campaign`.
2019-11-28 14:03:29 -05:00
Goober5000 e6f1332980 add game_settings feature to ignore single missions 2018-08-17 18:32:58 -04:00
asarium eeed22b91a Enable misc-unused-parameters
clang-tidy was used for fixing the warnings. It is not clear if this is
actually an improvement so this may still be disabled later.
2018-04-25 11:57:55 +02:00
asarium e28ebc2a6c Enable and fix misc-suspicious-string-compare check 2018-04-25 11:13:19 +02:00
asarium 0b4ca71eba Enable modernize-deprecated-headers 2018-04-25 11:12:41 +02:00
asarium 8f06e338a4 Add typesafe handle types and use it in game sound system
This adds a new class which allows to create type safe resource handle
types. At the moment, the engine uses ints pretty much everywhere for
providing handles to resources created by the specific subsystems. Since
all ints are the same to the C/C++ typesystem it is perfectly legal to
pass a sound handle to the graphics API as a buffer handle which will
obviously cause issues.

This adds a new type called "ID" which is a wrapper class for a generic
handle but with added type safety. An instance of this class cannot be
passed to a function expecting another type of handle which provided
compile-time type safety for these APIs.

As an initial test I converted the game sound handles to this new type.
I already found a bug in the mainhall system thanks to this new type.
The mainhall used the game sound handles as sound instance handles which
probably meant that that specific code never really worked right. I
removed the code since there was no better alternative for fixing it.
2018-04-22 16:22:45 +02:00
asarium 47967cb72a Reset campaign room text pointers when freeing campaign data
Previously the campaign room caused a heap-use-after-free error
(detected by AddressSanitizer) when loading the campaign failed two
times. This fixes the error by resetting the text pointers to their
default values when freeing the campaign list data.
2018-01-04 14:41:42 +01:00
Goober5000 676fb4b17d better stats handling when switching or resetting campaigns 2017-08-26 16:40:16 -04:00
Goober5000 7d1365800f clean up old comments 2017-08-26 03:43:26 -04:00
Goober5000 66ce0acc17 toss out the campaign savefile if we are restarting a previously finished campaign 2017-08-26 03:38:20 -04:00
asarium 07107ce9b2 Fix newly introduced format warnings 2017-03-15 19:34:11 +01:00
MageKing17 377751ab28 Avoid crashing if certain interface artwork is missing.
Changes a few windows (tech room, campaign room, medal case, and HUD config menu) to issue Warnings instead of Errors if certain pieces of interface art are missing. If their mask bitmap is missing, they automatically close themselves and display the old "Sorry, this feature is available only in the retail version" popup from the demo, allowing FSO to run the demo data without crashing when you click on the wrong button.

It also restores the special demo popup for the campaign room, which allows you to at least restart the demo campaign without deleting and recreating your pilot.
2017-01-24 13:18:42 -08:00
asarium 7195ec9856 A few more fixes... 2017-01-04 00:28:22 +01:00
asarium f819db3ac5 More string const correctness fixes 2017-01-04 00:12:41 +01:00
asarium acab2d2c46 Fix campaign list spacing 2016-08-03 10:41:09 +02:00
asarium 16be3b7cc5 Add support for TrueType fonts
This allows to use standard TrueType Fonts for text rendering in FSO. It uses the NanoVG library which provides the ability of drawing 2D shapes. This library is used for most 2D operations now and can also be used directly by using the PathRenderer class.
2016-08-02 10:57:28 +02:00
asarium 1bcd5400d3 Move build system to CMake 2016-07-22 12:07:19 +02:00