Compare commits

...
1668 Commits
Author SHA1 Message Date
Tyler Blount 6b7fc0b6a3 Don't reset target restrictions during table load
Prevents an issue with load order causing target restrictions to be reset.
2020-05-20 14:45:24 -06:00
Tyler Blount 2e4bef0d09 Remove unneeded code and some style changes 2020-05-20 12:25:13 -06:00
Tyler Blount 172952cb0f Correctly implement fixes from #73 2020-05-20 12:25:13 -06:00
Tyler Blount 72c27bdbe8 CI and Lock fixes 2020-05-20 12:25:13 -06:00
Tyler Blount bd4de16007 Use correct comparison 2020-05-20 12:25:13 -06:00
Tyler Blount 2e560f2ddb Fix some CI errors 2020-05-20 12:25:12 -06:00
Tyler Blount d35d3d25f8 Finally fix no dumbfire
also some miscellaneous changes
2020-05-20 12:25:12 -06:00
Tyler Blount 2d5111f14b Perhaps this works? 2020-05-20 12:25:12 -06:00
Tyler Blount d95754d6b4 No Dumbfire fix
Another fix for MLMs associated with the No Dumbfire flag.
2020-05-20 12:25:12 -06:00
Tyler Blount 5e3d4c6cfd More fixes
Contains changes related to failed CI builds and feedback.
2020-05-20 12:25:12 -06:00
Tyler Blount deca820c9e Lost fixes
These were lost during a rebase at one point. Will leave this commit as separate to avoid issues in the future.
2020-05-20 12:25:12 -06:00
Swifty 21c298271b Initial commit of multilock missile features. 2020-05-20 12:25:11 -06:00
Goober5000 6ec28f6de5 Merge pull request #2389 from Goober5000/ai_goal_target_name_fix
make Goal_target_names dynamic
2020-05-19 23:27:40 -04:00
Goober5000 8667891fc2 use dynamic strings 2020-05-19 13:48:06 -04:00
Goober5000 5f74388790 add newline 2020-05-19 13:48:06 -04:00
Goober5000 067b250be9 make Goal_target_names dynamic
If ever there were more than 100 goal targets in a mission, the old version of ai_get_goal_target_name would start corrupting memory.  Rather than making a hacky workaround, this just makes it dynamic.
2020-05-19 13:48:06 -04:00
Goober5000 775984ae36 Merge pull request #2390 from Goober5000/xstr_revert
clean up handling of translated vs. untranslated English
2020-05-19 12:51:41 -04:00
Goober5000 3a7e604af9 Merge pull request #2401 from Goober5000/small_sexp_fix
make some debug code only run in debug
2020-05-19 12:50:19 -04:00
Goober5000 d4c429f3b1 Merge pull request #2394 from Goober5000/weapon_stats
Weapon statistics for comparison and extended descriptions
2020-05-19 12:49:35 -04:00
Goober5000 933f20efaa Merge pull request #2392 from Goober5000/modify_weapons_loadout_check
modify weapons loadout check
2020-05-19 12:48:59 -04:00
m!m 6ca29a79ba Merge pull request #2400 from asarium/build/clangReadability
Enable sensible clang readability checks
2020-05-19 17:04:29 +02:00
Goober5000 498e5ef42e make some debug code only run in debug
This code is highly inefficient (find_parent_operator() is O(n) for Num_sexp_nodes, and it runs every frame for all sexps with negative values) and should not actually be necessary.  But it is useful as a debug tool, so I added some #ifdef's.
2020-05-18 21:05:41 -04:00
asarium d29e236250 Enable sensible clang readability checks
This enables the clang readability checks that I found to be sensible. I
disabled a few that would have caused a lot of unnecessary warnings in
our code.
2020-05-18 20:57:19 +02:00
Goober5000 880005f758 or this 2020-05-16 14:22:46 -04:00
Goober5000 ec1a35f624 better variable name 2020-05-16 14:22:46 -04:00
Goober5000 575573334b modify weapons loadout check
Based on feedback, this PR now allows gaps in weapon loadouts, but if any gaps exist they must come at the bottom.
2020-05-16 14:22:46 -04:00
Goober5000 82b9a392e1 fix CI thing 2020-05-16 14:22:00 -04:00
Goober5000 ab2a2d46d6 make cmdline-friendly 2020-05-16 14:22:00 -04:00
Goober5000 b0f812b808 some fixes 2020-05-16 14:22:00 -04:00
Goober5000 7e8ffcec86 also list weapons whose base weapon is player-allowed 2020-05-16 14:22:00 -04:00
Goober5000 7a9bebecf6 fix multiplier based on new info 2020-05-16 14:22:00 -04:00
Goober5000 c005aa5ce2 tweak 2020-05-16 14:22:00 -04:00
Goober5000 1d00c296dd include additional missiles 2020-05-16 14:22:00 -04:00
Goober5000 dd4036d8df add useful comment 2020-05-16 14:22:00 -04:00
Goober5000 4b42829aa0 MVP weapon stats, and fix shockwave determination 2020-05-16 14:22:00 -04:00
Goober5000 7f8eaa275c weapon stats for spreadsheet 2020-05-16 14:22:00 -04:00
Goober5000 329fd023ec Merge pull request #2396 from Goober5000/2298_followup
revert the clang-tidy changes from #2298
2020-05-16 14:20:04 -04:00
Goober5000 2e0a84010e revert the clang-tidy changes from #2298
These are far too pedantic, and were not related to the feature in #2298 anyway.
2020-05-16 00:01:06 -04:00
Goober5000 9e0c37364c Merge pull request #2298 from asarium/feature/pureLuaScriptTable
Add capability to have a pure lua script
2020-05-15 15:39:46 -04:00
Goober5000 d83d1b41ee make clang happy 2020-05-15 15:34:54 -04:00
Goober5000 d26a12464c clean up handling of translated vs. untranslated English
Since the original release of FS2, internal strings have been translated to their English entries in strings.tbl but external strings have not been translated to their English entries in tstrings.tbl.  It appears that string translation was universal until it was disabled via a hack, probably due to FRED idiosyncrasies (see comment in `fred_init()`), and then not re-enabled for release.  PR #2343 re-enabled it, but this turned out to have undesirable side-effects since many mods used incorrect XSTR indexes for external strings.

This PR restores the previous behavior and also cleanly separates localization into translated and untranslated modes.  FRED will always run in untranslated mode.  FSO will run in translated mode for all languages except English, where it will run in untranslated mode UNLESS the new option `$Use tabled strings for the default language` is enabled in game_settings.tbl.
2020-05-14 19:19:52 -04:00
Goober5000 f80693213c Merge pull request #2387 from Goober5000/fix_improper_ai_get_goal_target_name
fix improper usage of ai_get_goal_target_name
2020-05-14 19:08:21 -04:00
Goober5000 dbc26548f5 Merge pull request #2377 from wookieejedi/fix-warp-flag-issues
Fix warp flag and code issues
2020-05-13 23:41:31 -04:00
Goober5000 1ef90d79c4 Apply suggestions from code review
some comment tweaks
2020-05-13 20:15:36 -04:00
Goober5000 caf3eaad98 fix improper usage of ai_get_goal_target_name
The ship goals dialog was incorrectly assigning a goal target name for every dockpoint, which could quickly cause the limit to be exceeded if the FREDder browsed a lot of dockpoints.

This also indicates a need to fix the goal target name system as the counter is never decremented.  That will be in a subsequent PR.
2020-05-13 03:05:17 -04:00
Goober5000 efbace48b8 Merge pull request #2332 from Goober5000/mantis_3147_flag
add an ai-profiles flag to govern the Mantis 3147 fix
2020-05-13 00:48:44 -04:00
Goober5000 d961fa1bb6 use mod_supports_version 2020-05-12 21:46:19 -04:00
Tyler Blount c6a999ab7a Merge pull request #2384 from TRBlount/fix/weapon_render_type
Make sure modular tables can overwrite weapon model info
2020-05-12 00:20:01 -06:00
wookieejedi 5df12322e5 Incorporate feedback 2020-05-11 18:05:21 -04:00
wookieejedi f7d474cb77 Merge branch 'master' into fix-warp-flag-issues 2020-05-11 16:35:37 -04:00
Tyler Blount 764a74dbd2 Make sure modular tables can overwrite weapon model info 2020-05-11 13:54:50 -06:00
Goober5000 1d471e254b Merge pull request #2342 from Goober5000/mantis_1947
implement Mantis 1947, treat ship comm systems the same as player comm systems
2020-05-10 15:36:45 -04:00
Goober5000 771d0c7a38 Merge pull request #2383 from wookieejedi/update-pow)-to-multiply
Update cases of pow(x,2) to just multiply values
2020-05-10 14:45:47 -04:00
wookieejedi 94bfb2fe75 Update cases of pow(x,2) to just multiply values
Having recalled that other SCP folks stated pow shoud not be used to do simple squaring, I figured it might be a good idea to update the two instances I found where that was the case.
2020-05-10 13:17:03 -04:00
Fabian Woltermann 8fd2813ddd Merge pull request #2382 from The-E/fix/particles_in_lab
do on-frame processing for particle effects in the lab
2020-05-10 17:38:11 +02:00
Fabian Woltermann a0180fc004 Init the particle system and use the correct frametime counter 2020-05-10 15:29:28 +02:00
Fabian Woltermann 7a6aa5334d do on-frame processing for particle effects in the lab 2020-05-10 13:20:18 +02:00
Goober5000 d8f388996d Merge pull request #2376 from The-E/feature/kill_ship_in_lab
Make explosions happen in the lab
2020-05-10 00:31:56 -04:00
wookieejedi da55499817 Merge pull request #2381 from wookieejedi/fix-texture-replace-with-showship
Fixes texture replace not working with show ship
2020-05-09 23:32:21 -04:00
wookieejedi e1dbcf4dd6 Add back in disabled check for future use of the engines ok function 2020-05-09 17:18:31 -04:00
wookieejedi cb5a1000a6 Fixes texture replace not working with show ship
This PR allows the `ship_render_show_ship_cockpit` function to properly detect replacement textures. Fortunately just a one line fix.
2020-05-09 15:48:34 -04:00
Fabian Woltermann 94bd8da5db Merge pull request #2373 from Goober5000/parse_tweaks
some code tweaks from an old branch
2020-05-09 20:21:01 +02:00
Fabian Woltermann 03926b8dde Merge pull request #2379 from The-E/fix/naked_int3_in_missionmessage
Remove naked int3() call in missionmessage
2020-05-09 18:44:18 +02:00
Fabian Woltermann 764bbac99f The original Volition code called Int3() here; since there is a way out that does not require us to crash, we should just not crash. 2020-05-09 10:43:13 +02:00
wookieejedi 280ff2d4f0 Incorporate feedback 2020-05-08 22:40:58 -04:00
wookieejedi 45775a0d97 One more update to the scripting function calls 2020-05-08 11:29:07 -04:00
wookieejedi c4d405e33e change to nullptr 2020-05-08 11:14:53 -04:00
wookieejedi 86e1ebaf08 fixed copy paste error with new script function 2020-05-08 10:34:20 -04:00
wookieejedi 82921467a5 Update ship.cpp 2020-05-08 09:58:35 -04:00
wookieejedi c2820f10c8 Updates and fixes multiple warp out related code 2020-05-08 09:53:32 -04:00
Goober5000 d52bddf0dc Merge pull request #2347 from EatThePath/disable-doublefire-take-2
Disable doublefire take 2
2020-05-08 02:01:40 -04:00
Fabian Woltermann cd88663a92 Avoid a signed/unsigned comparison 2020-05-08 07:56:08 +02:00
Goober5000 0e9a72a37b make clang happy 2020-05-07 21:57:18 -04:00
Fabian Woltermann 1c10479d2f Pause the AI while in the lab 2020-05-07 22:27:47 +02:00
David Gibson b88ccfb924 added an explanatory comment. Also reunited some related code I'd inadvertantly pushed apart, per review. 2020-05-07 15:09:19 -05:00
Fabian Woltermann 11e9fa27c6 REdo a few things 2020-05-07 22:00:19 +02:00
Fabian Woltermann f4f6e74456 Add new "Actions" window to the lab viewer and add a "Destroy Ship" action to make explosions happen 2020-05-07 21:35:25 +02:00
Fabian Woltermann de2e9ada72 WIP 2020-05-07 21:34:12 +02:00
Fabian Woltermann 4005a60b32 Merge pull request #2375 from The-E/fix/damage_lightning_in_lab
Make the lab's "show damage lightning" flag work again.
2020-05-07 21:31:48 +02:00
Fabian Woltermann 2e6306d85f Merge pull request #2374 from The-E/fix/texture_replacement_in_lab
Apply tabled texture replacements when loading ships in the F3 lab
2020-05-07 20:36:16 +02:00
Fabian Woltermann e1f231fcf0 Use the tabled max hull strength instead of a constant 2020-05-07 19:01:36 +02:00
Fabian Woltermann 86e898c9ea Use modern loops 2020-05-07 16:04:06 +02:00
Fabian Woltermann df1491fd9e Make the lab's "show damage lightning" flag work again.
Note that it may take a few frames for lightning to disappear when unchecking that checkbox.
2020-05-07 15:18:56 +02:00
Fabian Woltermann 0b8f203371 Apply tabled texture replacements when loading ships in the F3 lab 2020-05-07 14:48:14 +02:00
wookieejedi 1d152fcc73 Merge pull request #2371 from wookieejedi/on-depature-started-hook
Add `On Departure Started` Hook
2020-05-06 22:48:42 -04:00
Goober5000 c9fb046024 update header 2020-05-06 14:38:40 -04:00
Goober5000 c4b8020ebc some code tweaks from an old branch
Minor edits from an obsolete branch that are still useful in cleaning up the code.
2020-05-06 14:25:08 -04:00
wookieejedi a2c7a344da Add On Departure Started Hook
This PR adds a scripting hook which triggers when a ship begins it's departure process. It has one variable that is the ship. I have tested and it works as expected. This new hook is very useful for triggering events whenever a ship needs an alteration to it's departure methods. For example, in Fate of the Galaxy we require ships to warp out along a certain vector. This hook allows us to see when the ship is begining that depature and then break the ship's warp, order the ship to instead follow a waypoint path, and then jump out.
2020-05-06 09:25:10 -04:00
Goober5000 f8e5c9f7a3 Merge pull request #2343 from Goober5000/fix_mantis_2942
implement XSTR check as described in Mantis 2942
2020-05-05 22:28:20 -04:00
wookieejedi bebb69e28f Merge pull request #2369 from wookieejedi/pain-flash-hook
Adds `On Pain Flash` Scripting Hook
2020-05-05 16:59:45 -04:00
Goober5000 aef4c1ba3c address feedback 2020-05-05 14:38:50 -04:00
Goober5000 801a6031e3 Merge pull request #2367 from Goober5000/aiturret_fix
fix some code rot
2020-05-05 14:01:34 -04:00
Goober5000 4c573e2989 Merge pull request #2368 from Goober5000/support_ship_override
add two useful cheat keys
2020-05-05 14:00:59 -04:00
wookieejedi aa4e300153 switch to correct hook type 2020-05-05 13:55:57 -04:00
wookieejedi 3695f0ff93 remove unneeded CHAPAINFLASH 2020-05-05 13:51:36 -04:00
wookieejedi 7dc38f7752 Update to new script format 2020-05-05 13:46:53 -04:00
Goober5000 5ab611a8b1 this reason is only applicable in debug builds 2020-05-05 12:08:22 -04:00
Goober5000 0577b69d69 address CI complaint 2020-05-05 11:48:46 -04:00
wookieejedi 6897024b29 Adds On Pain Flash Scripting Hook
This PR adds a scripting hook which triggers when the pain flash is shown. It has one variable that lists what type of flash was shown, shield with `Pain_Type == 0` and hull with `Pain_Type == 1` .  I have tested and it works as expected.
2020-05-05 10:03:48 -04:00
Fabian Woltermann ffd5fdc764 Merge pull request #2366 from wookieejedi/carry-glowmap-status
Updates glowmap settings for a ship to also apply to ship's cockpit
2020-05-05 10:21:53 +02:00
Goober5000 e985961ed5 add two useful cheat keys
`+Shift+R will enable or disable support ships

`+Shift+U will scan or unscan the targeted ship, or ship subsystem
2020-05-05 01:02:17 -04:00
Goober5000 89a722d41a placeholder for future feature implementation 2020-05-05 00:14:16 -04:00
Goober5000 3ca187127d move comment 2020-05-05 00:01:30 -04:00
Goober5000 35e67d4574 possibly fix some code rot 2020-05-04 23:33:06 -04:00
wookieejedi 8b7253cfc1 Updates glowmap settings for a ship to also apply to ship's cockpit
The sexps that activate and deactive glowmaps are very useful for ships, though previously the glowmap status was not passed to the ship's cockpit. This PR adds the ability for glowmap status to carry to this ship's cockpit (if it has one).
2020-05-04 22:07:49 -04:00
Goober5000 7ec425f341 Merge pull request #2345 from Goober5000/fix_mantis_2791
Fix mantis 2791
2020-05-04 20:27:29 -04:00
Goober5000 e4b2791c4e Merge pull request #2353 from Goober5000/support_ship_cleanup
clean up the support ship code a bit
2020-05-04 16:13:06 -04:00
Fabian Woltermann e5c2b76469 Merge pull request #2363 from The-E/fix/post_process_aa_cmdline
Unify the way post-process antialiasing is switched on
2020-05-04 22:12:39 +02:00
Goober5000 4c5bc1fa6c Merge pull request #2360 from Goober5000/fix_2335
fix issue 2335
2020-05-04 16:12:18 -04:00
Fabian Woltermann 857a622caa Make Travis happy 2020-05-04 21:29:53 +02:00
Fabian Woltermann bdc6145b2c Deprecates the -fxaa and -smaa cmdline parameters in favour of a more generalized -aa; This also ensures that the smaa render targets are always initialized. 2020-05-04 18:30:11 +02:00
wookieejedi 07ce8a9c70 Merge pull request #2362 from wookieejedi/fix-glowmap-explode-flag
Fix Glowmap flag not carrying over to final ship explosion
2020-05-04 07:35:36 -04:00
wookieejedi e42ed47c61 Previously if a ship's glowmaps were deactivated via sexp, then the glowmaps would reaactivie at the ship's final explosinos. This PR fixes that by carrying that flag into the ship explosion FX code.
Previously if a ship's glowmaps were deactivated via sexp, then the glowmaps would reaactivie at the ship's final explosinos. This PR fixes that by carrying that flag into the ship explosion FX code.
2020-05-03 23:36:42 -04:00
Goober5000 ce3b9b62b1 Merge pull request #2336 from Goober5000/hotkey_fixes
add +Hotkey Team: to override IFF designation in hotkey list
2020-05-03 17:29:35 -04:00
Goober5000 794863c5e7 Merge pull request #2348 from Goober5000/mantis_2867
bring save format up to date (Mantis 2867)
2020-05-03 15:42:48 -04:00
asarium 544029f66f Add capability to have a pure lua script
This adds the capability to have a Lua script that does not need to use
our table syntax at all but instead defines the hooks by calling API
functions. This also makes it possible to add hook functions at runtime
if the script requires that.

Also clean up some unused debug stuff.
2020-05-03 14:33:42 +02:00
Goober5000 38e04b6151 Merge pull request #2354 from Goober5000/cue_voice_tweak
add overlooked generic file
2020-05-02 16:48:56 -04:00
Goober5000 3c76cc6524 add overlooked generic file
It turns out that the extant placeholder wav has an underscore in the filename, so add that to the list.
2020-05-02 13:54:13 -04:00
niffiwan 3c7f73f4d8 Merge pull request #2349 from Goober5000/allow_empty_weapons_on_locked_ships
allow empty weapons on locked ships
2020-05-02 20:01:23 +10:00
Fabian Woltermann 5366073356 Merge pull request #2358 from The-E/fix/aa_shader_unloading
A followup to the recent SMAA fixes
2020-05-01 13:30:56 +02:00
Fabian Woltermann 23fbdf7e64 Clean up the aa shader loading/unloading code to handle cases where we switch between FXAA and SMAA correctly 2020-05-01 10:55:20 +02:00
Goober5000 5135cded94 Merge pull request #2357 from chief1983/datacorder
Use full path  in SFTP, unlike the FTP one this was modified from.
2020-04-30 22:42:12 -04:00
Cliff 519d1f59f8 Use full path in SFTP, unlike the FTP one this was modified from. 2020-04-30 16:02:03 -05:00
Fabian Woltermann b9be2ad85e Merge pull request #2356 from The-E/fix/smaa_presets
Fix bug in SMAA application
2020-04-30 13:05:58 +02:00
Fabian Woltermann 7121a3f748 Update the last_frame AA mode during cmdline parsing. 2020-04-30 11:08:25 +02:00
Fabian Woltermann 7439cf2cc3 wording 2020-04-30 10:57:54 +02:00
Fabian Woltermann 570dc5f3de Make sure the SMAA presets are actually passed to the shader stages and that the SMAA shader is recompiled at runtime if the preset changes. 2020-04-30 10:55:24 +02:00
Cliff Gordon 620fdbde08 Merge pull request #2352 from chief1983/datacorder
Fix Travis secure var declaration (use travis encrypt VAR='value')
2020-04-29 17:21:57 -05:00
Cliff fdb7e41ed4 Fix Travis secure var declaration (use travis encrypt VAR='value') 2020-04-29 14:32:08 -05:00
Goober5000 4cb3b393da clean up the support ship code a bit
Due to code rot, the support ship hull repair code was a bit more tangled than it should have been, so I tidied it up.  I also fixed a bug Sarn noticed where a support ship would think all subsystems were repaired if the hull repair rate was set to 0.
2020-04-29 01:39:18 -04:00
Goober5000 9c44e77da0 allow empty weapons on locked ships
As noticed in Discord, in loop1-2 some of your wingmen have missing weapons, but as the ships are locked it's impossible for the player to modify them.  These ships should not be part of the check.
2020-04-28 23:51:37 -04:00
Goober5000 d9d372121a missed one 2020-04-28 23:24:13 -04:00
Goober5000 f286363748 Merge pull request #2346 from EatThePath/ai_linkage_rot_cleanup
Set_primary_weapon_linkage cleanup as requested by Goober5000
2020-04-28 23:22:04 -04:00
Goober5000 6df90a8ec7 newline 2020-04-28 23:12:51 -04:00
Goober5000 289defdeff smol fix 2020-04-28 23:11:33 -04:00
Goober5000 a54ebc3114 bring save format up to date (Mantis 2867)
FSO-specific features should now all be properly marked off with checks for retail format.
2020-04-28 23:02:10 -04:00
David Gibson 4a5ff2860b now check doublefire validity flags before drawing doublefire HUD indicator 2020-04-28 16:06:20 -05:00
David Gibson f8f1b44405 Check doublefire flag validity before firing any missile 2020-04-28 14:50:33 -05:00
David Gibson f13faf4cba added new flags and flag loading for the doublefire disabling options 2020-04-28 13:57:44 -05:00
David Gibson 1520a21062 Code cleanup and rerodering in set_primary_weapon_linkage as requested by Goober5000 2020-04-28 13:02:47 -05:00
Fabian Woltermann cdc831b163 Merge pull request #2344 from chief1983/datacorder
Use datacorder in CI instead of fs2downloads
2020-04-28 16:34:25 +02:00
niffiwan 18718aee74 Merge pull request #2341 from wookieejedi/add_target_box_zoom
Adds Scaling for Target Box Models Separate from Techroom
2020-04-28 17:01:47 +10:00
Cliff c8a5ebe45c Since this is sftp now we don't need the alt ftp functionality. 2020-04-27 23:51:46 -05:00
Goober5000 9dd6bcf81d warn if there is a gap in the path sequence 2020-04-28 00:39:46 -04:00
Goober5000 3356edff2b warn if model paths do not have unique names 2020-04-28 00:16:06 -04:00
Goober5000 07acdde69a fix Mantis 2791
This is a pretty easy fix; sorry it took seven years!

Instead of firing an Int3() when a ship has no arrival paths, just log it and continue.  And change the upstream warnings, which should have been more visible, from WarningEx to Warning.
2020-04-27 23:43:45 -04:00
Cliff 29dd3e1057 Update Travis and AppVeyor CI to use our Datacorder account on FeralHosting instead of the swc.fs2downloads.com server, since it is having issues with uploads now. 2020-04-27 22:26:31 -05:00
Goober5000 c89ea8e8dd update test case 2020-04-27 23:22:34 -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 30d41eff8b fix issue 2335
Modify the early-out condition to remain in the function if we still need to render a dumbfire lead indicator.

Fixes #2335.
2020-04-27 20:32:45 -04:00
Goober5000 cc39cfe6f2 don't send builtin messages for ships with damaged comms, and don't select them when looking for unsilenced ships either 2020-04-27 16:32:43 -04:00
wookieejedi bca6f95621 add first time checks and use copy by assignment 2020-04-27 13:16:14 -04:00
wookieejedi e2010aeda1 Adds Scaling for Target Box Models Seperate from Techroom
Currently `$Closeup_Pos:` and `$Closeup_Zoom:` control the camera zoom and position values for the techroom, briefing and HUD Target Box. Unfortunately, with very large ships this results in an issue, to fit the view of an entire big ship in the HUD Target Box the zoom and position must be set a certain way which results in the ship looking very far away when viewed in the techroom. This PR adds two new fields that control camera postion and zoom but only for the HUD Target Box, thus modders can now set values for both and have the ships look good in both the Techroom and HUD Target Box. The new hud target box values are optional, and if not specifed they default to the values for `$Closeup_Pos:` and `$Closeup_Zoom:` .
2020-04-27 10:25:15 -04:00
Goober5000 d0daa43ccf since the code assumes all subsystems are dead if the ship is dying, add some flag checks to allow death messages to play (and be scrambled appropriately) if we have the ai_profiles flag active 2020-04-27 02:30:42 -04:00
Goober5000 e0cd2806f8 move quick-abort checks to before message priority checking
From the comments:

	// Do some checks to see if we are actually going to play this message at all.  These checks have been moved above the
	// "if ( Num_messages_playing )" block because we don't want to cancel an existing message if we have nothing to replace it with.

Additionally, by not incrementing `Num_playing_messages` if the code skips to `all_done`, this prevents messages that aren't playing from delaying messages in the queue that are actually valid and should play.
2020-04-27 02:24:26 -04:00
Goober5000 4f026a66ab fix small bug where speech was stopped when it wasn't supposed to be 2020-04-27 02:17:42 -04:00
Goober5000 28df82a03f fix bug where scramble status overrode subystem status 2020-04-27 02:13:08 -04:00
Goober5000 06f1b7d872 fix some int/bool stuff 2020-04-26 18:16:08 -04:00
Goober5000 1dfe3a8d9f implement Mantis 1947 feature request
This adds an ai_profiles flag that checks comm systems for non-player ships.  If their comm system is damaged, they will not send messages and you will not be able to issue squadmsg orders.

See also:
http://scp.indiegames.us/mantis/view.php?id=1947
2020-04-26 18:08:28 -04:00
Goober5000 aa46ae6639 add version-specific enabling of bugfix flags 2020-04-26 17:13:13 -04:00
Fabian Woltermann 22f3463397 Merge pull request #2339 from TRBlount/fix/lab_bg_smaa
Small F3 lab fixes
2020-04-25 18:59:48 +02:00
Goober5000 283e1555ba Merge pull request #2340 from JohnAFernandez/vmd-expansion
Add an angles version of zero vector and identity matrix
2020-04-25 11:54:23 -04:00
JohnAFernandez fe8ce74037 Use a constant for declaring angles with no measure 2020-04-25 09:54:40 -04:00
JohnAFernandez c43fa8c9a8 Add an angles version of zero vector and identity matrix 2020-04-25 00:45:34 -04:00
Tyler Blount 5c7fce41f1 Some lab fixes 2020-04-23 23:51:30 -06:00
Fabian Woltermann 0985091f6a Merge pull request #2338 from wookieejedi/music-restart-fix
Reinstates necessary soundtrack function call on level load
2020-04-21 18:33:43 +02:00
wookieejedi 2da7c4e761 Reinstates necessary check for soundtrack on level load
This updates #2299 and restores the use of `event_music_level_start(-1)` in `freespace.cpp`. This call was removed in #2299 because it was thought to be redundant but removal of that call resulted in music not playing upon mission restarts. This PR restores that call and fixes that issue.
2020-04-21 11:00:49 -04:00
m!m 6f109508d0 Merge pull request #2322 from asarium/feature/hookDocumentation
Add extended scripting hook system
2020-04-19 11:28:35 +02:00
Goober5000 e84919fa88 Merge pull request #2331 from Goober5000/interval_msecs
allow intervals and chain delays to use milliseconds
2020-04-18 15:32:17 -04:00
Goober5000 684354c8bd Merge pull request #2334 from Goober5000/fix_2333
fix loading of capship custom weapons
2020-04-16 15:09:36 -04:00
Goober5000 c8b1f56a09 missed one 2020-04-16 13:37:36 -04:00
Goober5000 8cc9eb2352 change to bool, for great C++ justice 2020-04-16 13:20:39 -04:00
Goober5000 3d08119734 add +Hotkey Team: to override IFF designation in hotkey list
This is in response to Mantis 1424:
http://scp.indiegames.us/mantis/view.php?id=1424

Since retail, the hotkey lists have been determined based on what attacks the player.  Mod makers may want to change this, so this PR adds the following options:

Default - retail behavior
Friendly/Enemy (or Hostile) - display in the specified list regardless of who attacks whom
None - don't display in the hotkey list at all

This PR also slightly cleans up the hotkey list function with a small optimization and a few tweaky fixes for edge cases.
2020-04-15 13:47:11 -04:00
Goober5000 45c3ee0b3c this probably makes more sense 2020-04-14 23:52:14 -04:00
Goober5000 89eea8e5d3 this pilot-specific logic should only run for the Pilot subsystem 2020-04-14 23:32:02 -04:00
Goober5000 6f5e500a1e add an ai-profiles flag to govern the Mantis 3147 fix 2020-04-14 17:50:16 -04:00
Goober5000 32730fc362 Merge pull request #2330 from Goober5000/check_no_briefing
actually fix the weapon-bank check
2020-04-14 17:19:11 -04:00
Goober5000 1c8f07b012 allow intervals and chain delays to use milliseconds
This adds the titular feature, as well as FRED support.  There are also some associated minor UI fixes in FRED and some cleanup in missiongoals.cpp.  And "Event Flags" are now a thing in case we want to add any other flags in the future.
2020-04-14 16:28:57 -04:00
Goober5000 892f0a831a actually fix the weapon-bank check
Ships which do not have the maximum number of primary and secondary banks (3 and 4) will have gaps in the loadout slots, so be sure to only check the weapon slots that the ship class is actually equipped with.
2020-04-14 14:38:18 -04:00
Goober5000 6b573bdbf6 Merge pull request #2329 from Goober5000/check_no_briefing
add a missing edge case to the weapon bank check
2020-04-14 12:07:20 -04:00
Goober5000 0e9ad8623b Merge pull request #2323 from Goober5000/fix_2314
sanity check missing numeric sexp arguments
2020-04-14 11:51:37 -04:00
Goober5000 f5edccd98f add a missing edge case to the weapon bank check
Yet another obscure edge case from Aftermath: Reboot.  The FREDder ought not to create this situation in the first place, but if he does, don't enter an endless loop.
2020-04-14 02:49:08 -04:00
Goober5000 007e7118f2 Merge pull request #2327 from Goober5000/jump_node_hud_distance
use consistent jump node distances on HUD
2020-04-13 18:34:27 -04:00
Goober5000 ae41e355ac reduce duplicate code 2020-04-13 16:56:18 -04:00
Goober5000 43d51792f2 apply formatter 2020-04-13 16:56:18 -04:00
Goober5000 f739a3e5c1 fix clang complaint 2020-04-13 16:56:18 -04:00
Goober5000 33c3f556a4 sanity check missing numeric sexp arguments
In the SEXP parser, zero-length strings are valid, as are zero-length operators.  But zero-length numbers are interpreted as missing arguments, since their only syntactic separators are spaces and the parser skips over whitespace.  And in any case, zero-length numbers are not semantically valid anyway.  This PR adds a sanity check to intercept all zero-length numbers, as well as malformed numbers, and convert them to 0.

This fixes issue #2314.
2020-04-13 16:56:17 -04:00
Goober5000 490464b656 Merge pull request #2324 from Goober5000/fix_Mantis_3171
Fix Mantis 3171
2020-04-13 16:54:56 -04:00
Goober5000 d526300483 Merge pull request #2325 from Goober5000/fix_Mantis_2715
prevent player leaving the loadout screen with incomplete weapons
2020-04-13 14:59:01 -04:00
Goober5000 3f3b284dcf use consistent jump node distances on HUD
There is a special function, `hud_find_target_distance`, which is used in most places for target distance.  However it wasn't used for jump nodes in this location.

Incidentally, the player's target's distance is cached, and this distance will always be current for the target box, so we can use the cached value and save a function call.
2020-04-13 14:53:28 -04:00
Goober5000 e0992ed88e add qtfred support 2020-04-13 12:29:02 -04:00
Goober5000 3997237a11 bump XSTR_SIZE and add NOLINT 2020-04-13 11:50:04 -04:00
asarium 1c12349990 Add extended scripting hook system
This moves towards defining the hooks in the code module that executes
them. Also provides the API necessary for better documentation of hooks.
This only covers a few hooks as a test and demonstration of the new API.
If no issues are found with this it can be extended in the future.
2020-04-13 14:45:19 +02:00
Goober5000 5f10b68118 Merge pull request #2326 from fjelliott/improved-subsystem-box-rendering
Cleaned up code that renders subsystem target boxes. (Follow-up to #2315)
2020-04-13 02:02:26 -04:00
Frans Elliott 91edcc4b8c Added a comment to describe the mathematics of subobj_find_2d_bound.
Broke up the projection function to aid in clarity.
2020-04-12 23:43:12 -05:00
Frans Elliott 4139cd890c Cleaned up subsystem bounding box code. 2020-04-12 21:24:13 -05:00
Goober5000 8fa96aeaf3 prevent player leaving the loadout screen with incomplete weapons
This is the best way to address Mantis 2715.  I took a look at allowing empty banks in the course of working on PR #2318, and it was completely intractable.  But in order to prevent certain "funnies" such as violation of bank restrictions, it's a good idea to ensure all banks are populated.

This PR adds a new XSTR for a popup message, and incidentally adds another XSTR to a message that should have had one already but didn't.
2020-04-12 21:34:00 -04:00
Goober5000 282ca0b0dd fix Mantis 3171 2020-04-12 20:39:16 -04:00
Goober5000 d3b1871837 remove Asserts that never worked because they checked invalid iterators 2020-04-12 20:39:16 -04:00
Goober5000 6f7ca147dd Merge pull request #2318 from Goober5000/additional_weapon_fix
simplify and fix the subsystem weapon loading code
2020-04-11 11:49:28 -04:00
Goober5000 ee391940d2 simplify and fix the subsystem weapon loading code
If ships have less than their full allocation of weapons, the code is supposed to compact the array so that these weapons all appear at the beginning.  This is done for small ships (fighters and bombers), but was not done for capital ships.  There was also a lot of code duplication with small ships getting extra error checking than capital ships.  This commit removes the duplicate code, makes the error checking more robust, and incidentally fixes the weapon array compacting for capital ships.
2020-04-08 12:31:43 -04:00
Goober5000 23dbfa5655 Merge pull request #2319 from Goober5000/weapon_info_scripting_fix
fix yet another issue uncovered by vectorization
2020-04-08 12:30:26 -04:00
Goober5000 8f1f308591 fix yet another issue uncovered by vectorization 2020-04-07 23:31:16 -04:00
Goober5000 cc456855e5 Merge pull request #2317 from Goober5000/weapon_bugfixes
Weapon bugfixes
2020-04-07 13:57:13 -04:00
Goober5000 0853c5bf7a clean up these functions in the same way as the weapon cheat functions 2020-04-07 02:20:56 -04:00
Goober5000 96de072bff add a useful assertion 2020-04-07 02:20:41 -04:00
Goober5000 2f0f2d7669 prevent access of out-of-range weapons, and at the same time sync primary and secondary capacity calculations 2020-04-07 02:02:22 -04:00
Goober5000 1c5a361d50 Merge pull request #2315 from fjelliott/master
Force subsystem targetting reticle to be square, even on non-square aspect ratios.
2020-04-06 01:11:56 -04:00
Frans Elliott 44072c026c Force subsystem targetting reticle to be square, even on non-square aspect ratios. 2020-04-05 21:21:37 -05:00
MageKing17 8cb9d311d7 Merge pull request #2312 from JohnAFernandez/target-signature-rename
Clarify Variable Names
2020-03-30 11:47:04 -07:00
MageKing17 bdec29f247 Merge pull request #2308 from Goober5000/vasudan_cheat_tweak
improve detection of vasudan main hall for cheats
2020-03-30 11:38:34 -07:00
JohnAFernandez 4e1b366f9f Clarify Variable Names
Use target_net_signature when talking about net_signature, but leave it at target_signature when talking about ai.target_signature.
2020-03-29 08:02:16 -04:00
Fabian Woltermann de2d1ec602 Merge pull request #2311 from asarium/fix/2310
Fix wrong matrix function calls
2020-03-29 13:37:19 +02:00
asarium 50e365a66c Fix wrong matrix function calls
This was using the wrong functions which caused videos not to show up
properly. This fixes #2310.
2020-03-29 12:19:00 +02:00
Tyler Blount a954a04cf8 Merge pull request #2309 from JohnAFernandez/Fix-ADE-invalid-defaults
Make sure aip->net_signature always defaults to -1 for no target.
2020-03-28 00:16:20 -06:00
Tyler Blount 030bbeb622 Merge pull request #2306 from Goober5000/flyby_sounds_refactor
refactor parsing of flyby sounds to make them optional
2020-03-28 00:15:33 -06:00
JohnAFernandez 6b7df053fa Make sure aip->net_signature always defaults to -1 for no target.
Although not used very often, ai_info.target_signature should be set to -1 whenever no target is specified, just like everywhere else to make sure that the code is as predictable as possible.

(Found while trying to figure out why the heck would the Object update packet send this at all??)
2020-03-27 23:11:19 -04:00
Goober5000 b8c135d162 improve detection of vasudan main hall for cheats 2020-03-25 14:24:37 -04:00
Fabian Woltermann b067e1ac66 Merge pull request #2307 from Goober5000/lab_weapon_bugfix
fix small error in lab
2020-03-24 21:34:58 +01:00
Goober5000 eabead6d41 fix small error in lab 2020-03-24 01:02:50 -04:00
Goober5000 ec50baa9d1 okay then 2020-03-24 00:11:36 -04:00
Goober5000 66f7bc4f50 add newline at end of file 2020-03-23 21:00:02 -04:00
Goober5000 44b7d5a4bd refactor parsing of flyby sounds to make them optional 2020-03-23 20:27:28 -04:00
Goober5000 caebad7077 Merge pull request #2302 from Goober5000/xmt_remove
Xmt remove feature
2020-03-18 09:48:42 -04:00
Goober5000 0caa65a74f address feedback 2020-03-17 17:22:27 -04:00
Goober5000 ff05816e11 add parse blacklist 2020-03-15 20:31:28 -04:00
Goober5000 da326f31f6 additional tweaks after rebase 2020-03-15 17:52:34 -04:00
Goober5000 376a01e82b wip 2020-03-15 17:42:57 -04:00
Goober5000 dc2ce094fc wip 2020-03-15 17:39:21 -04:00
Goober5000 74a0346e0d Merge pull request #2301 from Goober5000/static_cast_tweak
add functions to remove the clutter of static casts for ship and weapon info vectors
2020-03-15 15:08:42 -04:00
Goober5000 3b0d20aaf2 fix clang complaint 2020-03-15 01:35:12 -04:00
Goober5000 a0951f4e28 derp 2020-03-15 00:28:07 -04:00
Goober5000 3da2b99144 maybe these need to be extern'd 2020-03-14 15:13:44 -04:00
Goober5000 c9df8a13f1 add functions to remove the clutter of static casts for ship and weapon info vectors 2020-03-14 13:02:12 -04:00
Goober5000 247d5c453c Merge pull request #2294 from Goober5000/weapon_info_vector
Turn Weapon_info into a vector
2020-03-14 12:30:45 -04:00
Goober5000 5b8e89f37d address feedback 2020-03-14 09:56:56 -04:00
Fabian Woltermann f6083b680a Merge pull request #2299 from The-E/fix/2296_actually_fix_2292
As it turns out, the soundtrack reset issue is a bit more complicated…
2020-03-12 20:29:33 +01:00
Goober5000 fde7fdd854 address feedback 2020-03-07 13:35:17 -05:00
Fabian Woltermann 64531798e7 As it turns out, the soundtrack reset issue is a bit more complicated than I initially thought. The force_soundtrack check I previously removed was apparently vital; without it, calling event_music_level_init() (which in actuality is used to start soundtrack playback!) will result in the music being stopped, as the current soundtrack is set to -1.
This PR refactors the function's name to something more indicative of what it actually does, and removes a call made to it from within freespace.cpp which, due to changes in how the soundtrack system works, is now redundant and doesn't actually do anything anymore.
2020-03-07 19:04:01 +01:00
m!m ecd1cfe59c Merge pull request #2297 from asarium/fix/monoSoundAssert
Fix assertion when playing downsampled sounds
2020-03-07 15:34:09 +01:00
asarium 638bcacb71 Fix assertion when playing downsampled sounds
The sound was passed the data from before the resampling took place so
it though it would be playing a stereo sound and rightly cause an
assertion. This fixes that by refreshing the properties after appliying
the resampling properties.
2020-03-07 13:30:30 +01:00
Fabian Woltermann 4fc82ba334 Merge pull request #2295 from Goober5000/fix_weapon_info_pointer
fix an incorrect optimization
2020-03-07 12:59:23 +01:00
Goober5000 7ebd00e6f5 another fix for CI 2020-03-06 15:48:50 -05:00
Goober5000 fc41984a75 yet another fix for CI 2020-03-06 14:28:39 -05:00
Goober5000 45b5399f08 another fix for CI 2020-03-06 14:03:33 -05:00
Goober5000 fe15752f5e another fix for CI 2020-03-06 12:53:08 -05:00
Goober5000 c0a7be50b4 fixes for CI 2020-03-06 12:23:40 -05:00
Goober5000 bb8fcd428e address feedback 2020-03-06 03:11:31 -05:00
Goober5000 641aa329a5 fix an incorrect optimization 2020-03-05 22:58:00 -05:00
Goober5000 d86332a9d9 fix references 2020-03-05 22:46:07 -05:00
Goober5000 d8e88c1644 oof 2020-03-05 22:31:13 -05:00
Goober5000 1926d3c341 oof, more changes 2020-03-05 20:49:16 -05:00
MageKing17 c502d9bdf7 Merge pull request #2293 from scp-fs2open/fix/2292_reset_soundtrack_index_on_mission_close
Reset the current soundtrack during mission shutdown
2020-03-05 17:02:07 -08:00
Goober5000 20835adef6 convert Weapon_info to a SCP_vector 2020-03-05 19:12:43 -05:00
Fabian Woltermann af5e834250 Also make sure that Current_soundtrack_num is reset whenever event_music_level_init is called 2020-03-05 20:34:00 +01:00
MageKing17 e9051933b9 Merge pull request #2291 from Goober5000/remove_cloakmap
remove CLOAKMAP
2020-03-05 11:21:03 -08:00
Fabian Woltermann bb48ea9c61 Reset the current soundtrack during mission shutdown 2020-03-05 20:15:20 +01:00
Goober5000 939be80c30 wip 2020-03-05 00:01:03 -05:00
Goober5000 732ada474b remove CLOAKMAP 2020-03-04 23:47:22 -05:00
Goober5000 23b5320ec4 Merge pull request #2289 from MageKing17/bugfix/fred-rc-version-refix
Restore fred.rc version fix.
2020-03-02 08:56:34 -05:00
Goober5000 e3f67146b1 Merge pull request #2290 from Goober5000/log_newline
add newlines to mprintf and nprintf
2020-03-02 08:55:24 -05:00
Goober5000 cacee6e5b8 a few more 2020-03-02 01:07:17 -05:00
Goober5000 90c6c91e4f add newlines to mprintf and nprintf 2020-03-02 00:51:58 -05:00
MageKing17 0748ac191c Restore fred.rc version fix.
PR #1514 made this change to avoid having to constantly update fred.rc with new FSO versions, but it was inadvertently reverted in commit 9ac97f24223a7446d4364acfdb451c90697d6577; this also reverts PR #2286, since that's a somewhat more hackish solution to the same problem.
2020-03-01 18:10:23 -08:00
Goober5000 98cb4b6400 Merge pull request #2287 from Goober5000/briefing_stage_1_based
change briefing stage hook to 1-based
2020-03-01 15:36:47 -05:00
m!m 48d1797009 Merge pull request #2288 from asarium/docker-buildOnTagPush
Build docker standalone image on tag push
2020-03-01 16:14:54 +01:00
asarium 50ea017e59 Build docker standalone image on tag push 2020-03-01 14:48:47 +01:00
m!m c42cd25b89 Merge pull request #2284 from asarium/build/makeFFmpegOptional
Make FFmpeg an optional requirement
2020-03-01 11:55:01 +01:00
Goober5000 75099171ef Merge pull request #2286 from Goober5000/fred2_version_small_fix
Fred2 version small fix
2020-02-29 21:57:12 -05:00
Goober5000 809d11e1a8 change to 1-based 2020-02-29 19:21:21 -05:00
Goober5000 dadc65178d update the version number 2020-02-29 13:45:26 -05:00
m!m 52b17c3f8a Merge branch 'master' into build/makeFFmpegOptional 2020-02-29 18:48:13 +01:00
Goober5000 28722d7402 update the version number 2020-02-29 12:34:46 -05:00
m!m bf4243c0b0 Merge pull request #2285 from asarium/docker/fixEventHandling
Fix standalone signal handling
2020-02-29 18:33:46 +01:00
m!m 9dd6d9c874 Merge pull request #2278 from asarium/feature/betterScriptingDeprecation
Improve error message for deprecated functions
2020-02-29 18:33:31 +01:00
m!m 53a3b2b1c7 Merge pull request #2279 from asarium/fix/docker_stuff
Add compile time option to enable logging in release builds
2020-02-29 18:20:26 +01:00
asarium 2dc2295a59 Make FFmpeg an optional requirement
This does some refactoring to make it possible to cimpile and run FSO
without needing to link to FFmpeg. Since that eliminates support for
cutscenes or sound this is mostly useful for running a standalone server
which has no need for this anyway.

This reduces the image size of the standalone Docker image to only 20MB
and also resolves any licensing issues that might have existed.
2020-02-29 17:24:56 +01:00
asarium 582c144cf7 Fix standalone signal handling
The standalone did not initialize SDL and so did not receive the quit
signal when it was sent SIGTERM or SIGINT. This fixes that by making the
standalone server just use the normal os initialization code.

Also includes some other code cleanup and some more logging to make it
more apparent in the log what is currently happening at standalone
startup.
2020-02-29 17:09:55 +01:00
m!m e32cadd06a Merge pull request #2280 from asarium/docker/standalone-image
Add Dockerfile for compiling minimal standalone image
2020-02-27 18:12:30 +01:00
asarium ed6ac7060e Add Dockerfile for compiling minimal standalone image
This adds a Dockerfile which compiles FSO for the alpine Linux
distribution and then creates a standalone image based on those
binaries. That sidesteps the problem that existed with trying to use the
AppImage binaries on that distribution.

This produces a much smaller image (78MB instead of 230MB) so it should
be a bit more managable. Building can be done like this:
docker build --build-arg build_type=FastDebug -t scpfs2open/fso-standalone -f docker/standalone/Dockerfile .
2020-02-26 20:01:31 +01:00
asarium 7029e4a10f Add compile time option to enable logging in release builds
This mostly meant for special docker standalone server builds where it
might be useful to have full release performance but also have the logs
available if necessary. This now always compiles the log statements but
enables or disables them with a constexpr so they should not appear in
actual release binaries.
2020-02-24 18:54:55 +01:00
m!m 4d2cf1d2e0 Merge pull request #2263 from asarium/vulkan/test
Add Vulkan instance and surface creation code
2020-02-23 17:52:56 +01:00
asarium d31b2a971b Improve error message for deprecated functions
This will provide a proper error message when such a function is called
that will mention the name of the function and that it is deprecated and
cannot be used anymore in the targetted engine version.
2020-02-23 16:40:54 +01:00
m!m 74cf0b839d Merge pull request #2276 from asarium/fix/docker_stuff
Add option for logging to stdout
2020-02-23 14:32:08 +01:00
asarium 7f286b726d Add option for logging to stdout
This will make it easier to get logs from FSO running in a docker
container since logging to stdout is the easiest solution there.

Also includes some other changes that will make this work better in
Docker containers.
2020-02-23 13:09:51 +01:00
Goober5000 b0da0ea404 Merge pull request #2272 from Goober5000/briefing_stage_hook
add scripting hook for briefing stage
2020-02-18 14:38:24 -05:00
Goober5000 ca301fdb04 small adjustments 2020-02-18 01:18:07 -05:00
Goober5000 04244ec1ee Merge pull request #2273 from asarium/fix/2269
Handle invalid standard deviation properly
2020-02-17 15:26:56 -05:00
asarium 84b15afa8a Handle invalid standard deviation properly
If anything less than or equal to 0 was specified it would trigger some
kind of an assert in the standard library since that is not a valid
value for a normal distribution. Now a parse warning is generated and a
safe default value is used.

This fixes #2269.
2020-02-17 13:52:25 +01:00
Goober5000 a7063152b7 add scripting hook for briefing stage 2020-02-17 00:58:56 -05:00
Goober5000 5f938169af Merge pull request #2271 from asarium/fix/2266_again
Actually fix shader compilation error
2020-02-16 16:17:03 -05:00
asarium 8763b06c77 Actually fix shader compilation error
And actually compile the shader this time to check if the changes
actually fixed the error.
2020-02-16 13:02:25 +01:00
m!m 90a97021f5 Merge pull request #2267 from asarium/fix/2266
Fix compilation error in shader
2020-02-11 22:00:55 +01:00
asarium 3c6015f6b0 Fix compilation error in shader 2020-02-11 18:05:18 +01:00
Cliff Gordon ca4fcc84ea Merge pull request #2252 from pkubaj/patch-1
Fix build on FreeBSD
2020-02-11 09:35:09 -06:00
Cliff Gordon 94e74cb15f Merge pull request #2264 from pkubaj/patch-2
Fix build on big-endian architectures
2020-02-11 09:32:30 -06:00
pkubaj 3daa819042 Fix build on some LE platforms
Some platforms don't like those variables being unused.
2020-02-11 13:58:26 +01:00
pkubaj 4bb31f4e1b Fix build on big-endian architectures
swap_bsp_data() and swap_sldc_data() use those.
2020-02-10 15:49:52 +01:00
pkubaj 87c5544b7b Change to SCP_BSD 2020-02-10 15:47:17 +01:00
pkubaj 4914c4a452 Change to SCP_BSD 2020-02-10 15:46:56 +01:00
pkubaj 0b33a44004 Change to SCP_BSD 2020-02-10 15:46:30 +01:00
pkubaj 1f98551b12 Change to SCB_BSD 2020-02-10 15:45:57 +01:00
Goober5000 463caecf03 Merge pull request #2262 from niffiwan/fix/issue2261
make small bombs appear smaller in hud targetbox
2020-02-09 14:24:49 -05:00
asarium 2f3f061e75 Add Vulkan instance and surface creation code
This adds a new graphics type for the Vulkan graphics API. All this does
is to create a vulkan instance and a presentation surface with the help
of SDL.
2020-02-09 17:06:21 +01:00
niffiwan 0c0c4ddaef make small bombs appear smaller in hud targetbox
Also cleaned up the code slightly, the factor variable was only used
when missile_view was false
2020-02-09 21:07:04 +10:00
m!m 3fb2f97b43 Merge pull request #2133 from asarium/feature/moreOptionsUI
Add more features for the new Options UI
2020-02-09 11:39:18 +01:00
Goober5000 66daf6ba24 Merge pull request #2259 from Goober5000/update_wiki_cmdling
bring cmdline listing up to date with wiki (update links etc)
2020-02-09 00:55:42 -05:00
asarium a13b503b83 Add more features for the new Options UI
The largest new feature is that it is now possible to include other
files into the RML by using the "include" tag. This is useful for making
markup files more modular.

Also added some more options for existing things (e.g. built-in detail
options).
2020-02-08 13:28:53 +01:00
Goober5000 43a29b4dec address feedback 2020-02-07 12:00:01 -05:00
niffiwan 1c2d8a3b47 Merge pull request #2257 from asarium/gr/genericUniformBlock
Add generic uniform block for low frequency data
2020-02-07 18:06:40 +10:00
MageKing17 aa0a1ae3ed Merge pull request #2253 from scp-fs2open/bump_version
Update Version to 20.1.0
2020-02-05 11:39:11 -08:00
Goober5000 1d12157a07 bring cmdline listing up to date with wiki (update links etc) 2020-02-02 15:46:50 -05:00
asarium ae026f83ca Add generic uniform block for low frequency data
This elimiates all of the remaining "old style" uniforms from our
shaders. This might not be optimal for all situations but I have
confirmed that it is at least not worse at the moment.
2020-02-01 19:18:14 +01:00
Goober5000 facf17a222 Merge pull request #2254 from Kiloku/master
Update changelog with 19.0.0 release
2020-01-29 14:08:46 -05:00
Kiloku bf99541c58 Merge pull request #2 from scp-fs2open/master
Update
2020-01-29 13:32:25 -03:00
Kiloku 34391ebe21 Update changelog with 19.0.0 release 2020-01-29 13:30:49 -03:00
Fabian Woltermann 93f71ec202 Merge pull request #2247 from asarium/gr/matrixUniforms
Use uniform blocks for matrices
2020-01-29 11:04:22 +01:00
m!m e504f6b59e Set minor version to 1
This should be a bit more consistent with how we did versioning before.
2020-01-28 21:29:09 +01:00
m!m 133821952f Update Version to 20.0.0 2020-01-28 21:21:36 +01:00
asarium d7602ec9d1 Disable MinGW in GitHub actions
It fails with the same message as Travis CI :(
2020-01-28 18:20:47 +01:00
asarium fe5dbeccaa Use uniform blocks for matrices
This is a generic way to get matrix data to shaders without using
(old-school) uniforms. This is another step towards more compatibility
with how new APIs (Vulkan) do things to increase the odds for a Vulkan
port at some point.
2020-01-28 18:20:47 +01:00
pkubaj d7e40d2bcc Fix build on FreeBSD
sys/socket.h is needed for AF_INET.
2020-01-28 16:31:23 +01:00
pkubaj 0251fd347f Fix build on FreeBSD
sys/socket.h is necessary for AF_INET.
2020-01-28 16:30:53 +01:00
pkubaj 1cce2d70a3 Fix build on FreeBSD
sys/socket.h is necessary for AF_INET.
2020-01-28 16:30:23 +01:00
pkubaj 68f5b7d524 Fix build on FreeBSD
FreeBSD is similar to Linux and MacOS here.
2020-01-28 16:28:45 +01:00
niffiwan 036d5ed780 Merge pull request #2244 from JohnAFernandez/More-Multi-Cleanup
CleanUp Unused Function
2020-01-28 19:58:09 +10:00
niffiwan c109562c40 Merge pull request #2251 from wookieejedi/fix-rtt-target-display
Fixes RTT Target Box Scaling
2020-01-28 19:56:24 +10:00
niffiwan 0334b3c287 Merge pull request #2249 from wookieejedi/fix-hasfilter-on-weapons-hud
Fix weapon names not filtering # in HUD gauge
2020-01-28 07:06:57 +10:00
wookieejedi 9039081fa7 formatting 2020-01-27 12:23:15 -05:00
wookieejedi 73a5ac7665 specify floats 2020-01-27 12:17:26 -05:00
wookieejedi 6c2e419825 Fixes RTT Target Box Scaling
It seems that when RTT for cockpits was added that the scaling of ships in the target box fell through the cracks. Properly specifying the `clip_aspect` fixes the issue. This PR fixes issue #2250.
2020-01-27 10:04:57 -05:00
wookieejedi c2c2042a38 remove unneeded string filtering 2020-01-27 08:33:41 -05:00
wookieejedi da08ba5932 remove unneeded line 2020-01-26 15:10:32 -05:00
wookieejedi bc14149e84 Fix weapon names not filtering # in HUD gauge
Weapon names with a `#` should not display text after that `#` in the HUD. For the most part this works, but there were a few cases this didn't (such as primaries using the weapon name). This PR fixes two spots that fell between the cracks.
2020-01-26 14:08:28 -05:00
Goober5000 6ceb2a276c Merge pull request #2243 from wookieejedi/allow-engine-wash-intensity
Allows Modders to Actually Use Engine Wash Intensity
2020-01-25 16:32:12 -05:00
m!m d8537843ab Merge pull request #1600 from asarium/opengl/persistentlyMappedBuffer
Add persistent buffer mapping support for uniform data
2020-01-25 21:44:47 +01:00
wookieejedi 539cad66e7 change placement and add reset values 2020-01-20 12:31:18 -05:00
JohnAFernandez b042b27310 Remove Another Unused Multi Function
This function used to help with the sequence number of packets, but that is now done in the object packet functions themselves.
2020-01-20 00:42:56 -05:00
JohnAFernandez 8ee447d8c2 CleanUp Unused Function
This function does not have any contents and should be removed.
2020-01-20 00:28:28 -05:00
wookieejedi 8a36fc138c Allows Modders to Actually Use Engine Wash Intensity
Previously, Engine Wash Intensity didn't actually do anything in the code. This adds a game table setting that let's modders specify to the game to actually take the intensity value into account when calculating engine wash effects.
2020-01-19 16:54:58 -05:00
m!m a86322c49d Merge pull request #2242 from asarium/feature/deprecatedPostProcess
Add -post_process to deprecated flags section
2020-01-19 16:07:00 +01:00
asarium b19d7def54 Add -post_process to deprecated flags section
This should avoid causing warnings to pop up when users still have this
in their command line.
2020-01-19 12:28:06 +01:00
m!m 34577df2ea Merge pull request #2240 from Goober5000/post_processing
Clean up launcher settings a bit
2020-01-18 15:58:08 +01:00
Allen A. Babb b56c0d8bff Merge pull request #2241 from wookieejedi/fix-default_disabled_control-setting
Fix overriding the default values in control table for `disabled`
2020-01-17 21:19:08 -06:00
wookieejedi 48164e447d Fix overriding the default values in control table for disabled
For some reason my repro had some critical issues and I was unable to comitt to the PR #2210. I have closed that PR and opened this one given the discussion in #2210. The result of that discussion was `but omit line 594`. That is what this PR does.
2020-01-17 19:49:05 -05:00
Goober5000 1f4867a640 Clean up launcher settings a bit
Three main changes in this PR:

1) The enums for the "easy settings" launcher options are now clearer and more explicit, and the enum assignments for a lot of graphics options are now fixed, as they were incorrect due to code rot.

2) Some of the command-line flags options have been recategorized: -window, -fullscreen_window, -nomotiondebris and -noscalevid are now Gameplay; and -fps is now HUD.

3) Since post-processing is required for nebula fading, it now defaults to on, and the flag has been changed to -no_post_process.
2020-01-16 18:14:03 -05:00
wookieejedi 648598c729 Merge pull request #2239 from scp-fs2open/revert-2236-add-scripting-support-gun_convergence
Revert "Adds Scripting Support for the Ship Flag `gun convergence`"
2020-01-14 18:22:19 -05:00
wookieejedi 0b6a642a17 Revert "Adds Scripting Support for the Ship Flag gun convergence" 2020-01-13 23:32:03 -05:00
m!m 939492b981 Merge pull request #2196 from JohnAFernandez/Mantis#2129
Mantis#2129 Address Rare Multi Crash
2020-01-13 20:44:11 +01:00
Goober5000 69393f9104 Merge pull request #2236 from wookieejedi/add-scripting-support-gun_convergence
Adds Scripting Support for the Ship Flag `gun convergence`
2020-01-13 14:38:57 -05:00
Goober5000 3a2c680caa Merge pull request #2238 from scp-fs2open/fix/no_emissive_light_flag_behaviour
Update cmdline.cpp
2020-01-13 11:18:50 -05:00
Fabian Woltermann db71f3d550 Update cmdline.cpp
This fixes #2237
2020-01-13 08:58:38 +01:00
asarium 0b2695e9e4 Some more security checks 2020-01-12 22:23:13 +01:00
wookieejedi 51bbb0c1d2 Adds Scripting Support for the Ship Flag Gun Convergence 2020-01-12 15:37:31 -05:00
asarium 362645ce27 Reformat code with clang-format 2020-01-12 12:57:00 +01:00
asarium 10ab4a00f5 Fix clang-tidy issues 2020-01-12 11:59:23 +01:00
asarium 5ce6c251ff Add persistent mapping support
Persistent buffer mapping is an OpenGL technique where the contents of a
buffer object are mapped to a persistent pointer instead of having to
map and unmap a buffer every time it is modified.

This decreases the overhead for updating data in a uniform buffer object
which now only consists of a memcpy and a flush call.
2020-01-12 11:59:23 +01:00
asarium a3651026b1 Improve how the engine handles uniform buffers
This is in preparation for using persistently mapped buffers for uniform
buffers. Since that functionality is not available in the OpenGL version
we are targetting I implemented a fall-back which simply uses
glBufferSubData.

I did a benchmark with these changes and there was no change in
performance to the current master version.
2020-01-12 11:59:23 +01:00
Goober5000 6f18d93a23 Merge pull request #2234 from asarium/fix/warningsInParselo
Replace Warning with error_display in parselo
2020-01-11 18:38:52 -05:00
asarium 8e767bb613 Replace Warning with error_display in parselo
error_display shows the line where the error was detected. Warning
itself is pretty useless for parsing related errors so I replaced all
Warnings (where appropriate) with an equivalent error_display.
2020-01-11 21:57:52 +01:00
Goober5000 06df419429 Merge pull request #2233 from wookieejedi/cleanup-debuglog-output
Proposal to cleanup debug log statement regarding turret fire
2020-01-10 02:10:44 -05:00
Goober5000 98bafefc32 Merge pull request #2231 from JohnAFernandez/Fix-Interpolation
Better Timing For Interpolation Calc
2020-01-10 02:01:02 -05:00
wookieejedi 45e34797ae remove entirely 2020-01-09 23:29:23 -05:00
Goober5000 9eb7884968 Merge pull request #2232 from wookieejedi/fix-random-delay-firerate-calculation
Fixes calculations for random fire rates when using min and max delays
2020-01-09 21:51:13 -05:00
JohnAFernandez 2bdcd1bf04 Better Timing For Interpolation Calc
Does this by refactoring how the timing is calculated.  It also removes the Next Arrival Time Array, which does not actually do a good job of calculating it, anyway.  We can now rely on the other oo_arrive_time arrays exclusively by subtracting from current time.

Squashed Commits:
1. Use function to pull FrametimeOverall to keep from breaking Fred.
2. Remove unsed parameter from multi_oo_calc_interp_splines
3. And also fix the corresponding declarations and functions calls.
2020-01-09 19:34:54 -05:00
wookieejedi 00e750c120 Proposal to cleanup debug log statment regarding turret fire
In aiturret.cpp there is a mprintf, `mprintf(("nothing ok to fire\n"));` which greatly pollutes the debug log in missions with turreted ships. I'm not sure what this message helps debug, thus I propose commenting it out.
2020-01-09 18:03:21 -05:00
wookieejedi 6b872ef93c Fixes calculations for random fire rates when using min and max delays
Previously, using max and min delays resulted in guns firing that were not within the specified range. This PR fixes that while also simplfying the code. `frand_range` is already using in each of those functions so I figured it would be fine to use it and also simplify the code. That, instead of `next_fire_delay = (((float)rand()) / (((float)RAND_MAX + 1.0f) * (winfo_p->max_delay - winfo_p->min_delay + 1.0f) + winfo_p->min_delay))`.
2020-01-09 17:56:02 -05:00
Goober5000 07231d74e6 Merge pull request #2229 from wookieejedi/additional-initial-velocity-fixes
Cleanup Reaming Issues with Initial Velocity
2020-01-08 22:47:42 -05:00
Goober5000 78f113e806 Merge pull request #2230 from JohnAFernandez/Optimize-Multi-in-Debug-Builds
Remove Debilitating Debug Function Calls
2020-01-08 22:31:45 -05:00
wookieejedi da05fa18c5 use nullptr 2020-01-07 12:58:42 -05:00
wookieejedi 89576232a5 Few additional cleanups to hyperspace warpins with initial velocity 2020-01-07 11:08:06 -05:00
JohnAFernandez a73ccee28d Remove Debilitating Debug Functions
These function have been around since retail.  What they were supposed to do was allow the V team to get a baseline of how much data object updating would use without the limiting system.

However, the way that multi_rate_add work, is that they say to the limting system, "The client is getting a lot of data, so limit it some more." And that eventually causes debug build object updates to slow to a crawl.
2020-01-06 21:55:03 -05:00
wookieejedi 15b494b765 Cleanup Remaing Issues with Initial Velocity
This PR tidies up the comments in the initial velocity setting, properly sets the player's throttle, and cleans up issues with initial velocity setting and hyperspace warpin types.

Note the removed code block for hyperspace warpin ending was removed becuase it is not needed, as physics calculatios already handles that. Also the calculations that were there did not properly account for initial ship velocity setting.
2020-01-06 11:29:09 -05:00
Fabian Woltermann 49559c047f Merge pull request #2220 from wookieejedi/fix-min_max-firewait-oversight-for-turrets
Fix Min and Max Delays for Fire-rate not working for Turrets
2020-01-06 13:44:43 +01:00
Fabian Woltermann c6af310178 Merge pull request #2223 from wookieejedi/fix-setting-of-initial-velocity
Fix Setting of Initial Velocity
2020-01-06 13:43:21 +01:00
m!m 3013b76a46 Merge pull request #2224 from JohnAFernandez/Vector-Math-Description-Cleanup
vecmat.cpp quick cleanup
2020-01-06 12:13:08 +01:00
wookieejedi b32f2856fc consolidate variables 2020-01-05 22:57:22 -05:00
wookieejedi 1fdf2876d0 update comment 2020-01-05 21:34:36 -05:00
JohnAFernandez 790949b527 vecmat.cpp quick cleanup
A few early on descriptions in this file are inconsistent or even plain wrong.  This should correct that.

Also, rename vm_vec_imag() to vm_vec_inv_mag_quick() to better describe what it is.
2020-01-05 20:29:59 -05:00
wookieejedi 7d1acf0b08 Fix Setting Initial Velocity
It turns out that the code that set initial ship velocities did not account for local ship rotation changes. This bug is only noticeable when ships are very high speeds, high initial velocities, and have high drift values thus it was never recognized before. This PR fixes that by ensuring that the velocity vectors are set appropriately. As discussed with Goober on Discord, this fixed behaviour is indistingushable when using FS ships and most mods, this the behavipur will be on by default.
2020-01-05 16:45:24 -05:00
Goober5000 1d9eb94726 Merge pull request #2213 from Goober5000/verify_and_load_cleanup
Minor cleanup to Verify and loading bar
2020-01-04 13:51:02 -05:00
Goober5000 4503fc05d5 Merge pull request #2222 from asarium/fix/fogDepth
Fix fog depth computation
2020-01-04 11:52:58 -05:00
asarium 42953b0f0d Fix fog depth computation
This was previously using the wrong direction of the conversion so it
produced wrong values. This should fix that and should hopefully bring
the nebula experience back to how it is supposed to look.
2020-01-04 12:04:26 +01:00
wookieejedi a69e6b1e8e Fix Min and Max Delays for Firerate not working for Turrets
When the `+Max Delay:` and `+Min Delay` for `Fire Wait` were added they were only added to primary firing and not turret firing. Specifically, `turret_set_next_fire_timestamp` uses only `winfo_p->fire_wait` while `ship_fire_primary` uses the delays. Checking with the original author DahBlount they specified it was an oversight, thus this PR fixes that and allows the delays to now work properly with turret firerates.
2020-01-03 13:40:17 -05:00
Goober5000 072105a9c3 Merge pull request #2219 from wookieejedi/restore-3d-weapon-icons
Restore 3D Weapon Icons when Flag Used
2020-01-03 12:57:51 -05:00
wookieejedi 1578e4eab4 Restore 3D Weapon Icons when Flag Used
Overview: This PR restores all expected functionalility of the 3D weapon select flag while also providing modders with a way to use both 3D models and custom weapon icons.

PR #2055 provided a way for modders to use 3D weapons while still using specified weapon icons. Unfortunately that resulted in weapon icons not changing to an image of the 3D model when the 3d weapon selection flag was used. It was requested on the forum that this behaviour be restored. This PR restores that behaviour while still allowing modders to use 3D weapon models and their own weapon icons. Instead of the approach taken in PR #2055, this PR will automatically show a 3D weapon model if there is not weapon animation specified and if a weapon tech model is specified. Thus, if a modder wants to use their custom weapon icon but also have a 3D weapon model shown, they simply do not specify a model animation but do specify a tech model for the weapon (the 3d weapon selection flag does not need to be checked). If the 3d weapon selection flag is checked then the 3D weapon model will of course still be used, but the weapon icons will now show the image of the 3D model instead of any custom weapon icons the modder specified. In other words, the flag acts exactly as expected for the player.

I also tested this for each case and it works as desribed above.
2020-01-02 23:18:32 -05:00
m!m 1c23d90846 Merge pull request #2218 from asarium/cleanup/grDefs
Cleanup some unused functions in the graphics subsystem
2020-01-02 21:33:42 +01:00
asarium bfe507a53a Cleanup some unused functions in the graphics subsystem 2020-01-02 17:05:26 +01:00
MageKing17 bf82ffdf4b Merge pull request #2217 from Goober5000/fix_builtin_messages_sexp
fix disable/enable builtin messages for wingmen
2020-01-02 04:42:24 -08:00
Goober5000 0c26ad40e9 fix disable/enable builtin messages for wingmen
In the case of "any wingman", the sexp logic was flipped.
2019-12-30 18:55:09 -05:00
FSCyborg 56fd6f504a Mantis#2129 Address Rare Multi Crash
Should fix rare multi crash where reserving net signatures for spawened munitions would cause an ushort overflow, triggering an assert in multi_set_network_signature.

Turns out we can just remove the assert, and just guarantee that signature is going to be in the required range.

Squash history:
1. Improve Assertions (as per Taylor's suggestion) and reconfigure Int3
2. Wording change on last assertion
2019-12-28 00:50:35 -05:00
Goober5000 2521228666 accidentally a # 2019-12-27 15:25:41 -05:00
Goober5000 db6520c072 make the loading bar a bit more accurate by updating the count estimate to a recent 'real count' 2019-12-27 14:24:16 -05:00
Goober5000 09f06dc1ed rename VerifyEx to Verification and remove old MSVC 2005 checks 2019-12-27 14:22:44 -05:00
Goober5000 aee6ecb974 Merge pull request #2212 from JohnAFernandez/Fix-Multi_Crash
Urgent Multi Fix
2019-12-27 14:01:41 -05:00
JohnAFernandez b06761bc66 Urgent Multi Fix
Any server build created this year will crash any client connected to it because it will send a packet cotaining hull updating information, but accidentally unset the flag for new hull info. The client was therefore unaligned with the packet, causing the local subsystem_update array to go bonkers.
2019-12-27 11:35:25 -05:00
Goober5000 20e78143ee Merge pull request #2211 from JohnAFernandez/MultiUtil-Cleanup
Multiutil.cpp cleanup#1
2019-12-27 01:06:59 -05:00
JohnAFernandez 861eb14865 Clean Up Error Handling in multitutil.cpp
Removes about half of the Int3()'s in multiutil.cpp by making Assertions more robust, changing two functions to void type (because there was no way to get an error value from them, anyway), and adding two Verify()'s in case we ever decide to start using the multi variable change functions.

Squash History:
1) Forgot to change one Assert to Assertion
2) Change Verify to Assertion, because of better argument support.
3) Fix a couple copy paste errors
2019-12-26 07:59:14 -05:00
JohnAFernandez e34e3378a2 Modernize NULL to nullptr in Multiutil.cpp 2019-12-25 22:51:25 -05:00
FSCyborg 03125df50c Multiutil Minor Cleanup
Just a quick PR to make multiutil slightly more readable by removing one unused function (whose functionality is already in the object update packet), two globals which we only increment and we do nothing with, and some defines that have been commented out because the size returned can actually vary.
2019-12-25 22:06:38 -05:00
Goober5000 67613bbba0 Merge pull request #2209 from wookieejedi/fix-key-numbers-for-multi
Fixes accidental break with multi due to max key numbers
2019-12-23 17:42:10 -05:00
wookieejedi 4f5f3e859e remove keys 5-9 and 0 2019-12-23 16:05:35 -05:00
Goober5000 10bec9ff00 Merge pull request #2208 from CasparKielwein/ck/bitmanip_with_unsigned
make internal variables in static_rand unsigned.
2019-12-23 12:23:12 -05:00
wookieejedi a7e4a72622 add to button_function_critical() 2019-12-23 10:41:42 -05:00
wookieejedi 3167623e31 Fixes accidental break with multi due to key numbers
This PR reduces the number of custom controls back down to 127 so as to keep multi compatibility.
2019-12-23 10:36:23 -05:00
CasparKielwein c3a51296f8 make internal variables in static rand unsigned.
several of the bitwise manipulations on signed integers are technically undefined behaviour.
I made the internal variables unsigned and the results are then converted to signed ints as before.
This should not actually change any observable results.

Did some cleanup as well, while I was at it.
2019-12-23 10:52:33 +01:00
Goober5000 084cd65e97 Merge pull request #2202 from notimaginative/fix_trails_memory_bug
fix Trails.next pointing to invalid address
2019-12-22 12:09:52 -05:00
Goober5000 158448401a Merge pull request #2203 from notimaginative/fix_end_mission_on_death
avoid ending mission on death unless we should
2019-12-22 12:09:22 -05:00
MageKing17 bc5425166c Merge pull request #2206 from FSCyborg/Fix-Multi-Backend
Fix Multiple Multi Backend Issues
2019-12-21 19:25:01 -08:00
MageKing17 3da2bdc0ad Merge pull request #2205 from CasparKielwein/ck/clean_main_file
Refactore: cleanup freespace.cpp
2019-12-21 19:17:33 -08:00
FSCyborg b37c6b9052 Fix Multiple Multi Backend Issues
This fixes string comparison of ship names in multi.  Any respawned ship would be given a default name and would return false for any future name comparison.

The most visible affect of this was being given the default loadout and fighter on respawn instead of the fighter and weapons you selected, but Taylor was spotting a lot of potential other break points as he looked through other unrelated multi issues on mantis.

Squash History:
1) Fix comments and warning to be clearer.
2) Replace NULL with nullptr
2019-12-21 18:17:34 -05:00
CasparKielwein ca3dc4277f made lopps in freespace.cpp range based as per clang tidies request
in test_sound remove the redundant reset of the array lopp.
2019-12-21 21:03:21 +01:00
CasparKielwein 0f65314dd9 in labviewer_close_flags_window call vector.clear instead of empty.
Intent probably was to empty the vectors and not check for state empty.
This was most likely a bug, which was called by the no_discard attribute on the function.
2019-12-21 11:02:15 +01:00
CasparKielwein abaa891b00 cleanup of freespace.cpp replace NULL with nullptr and declare variables at use 2019-12-21 11:02:15 +01:00
CasparKielwein 176de9e928 remove unused code behind TIMER_TEST, it asks to get matt, who is long gone :) 2019-12-19 21:54:36 +01:00
CasparKielwein 84fb5e7610 remove unsused JOHNS_DEBUG_CODE 2019-12-19 21:54:36 +01:00
CasparKielwein 977a8aff91 remove unused compiler flag DYN_CLIP_DIST 2019-12-19 21:54:36 +01:00
CasparKielwein 06ead7c051 removed unused turret debug function in freespace.cpp 2019-12-19 21:53:55 +01:00
CasparKielwein 3d485af4cc remove framerate_check code in freespace.cpp which didn't do anything anymore. 2019-12-19 21:50:16 +01:00
CasparKielwein 7cde541390 remove unused functions in freespace.h
also remove the define STAMPER_PROGRAM, which the author
considered "yuck" in 1997, so lets do him the favor.
2019-12-19 21:50:16 +01:00
CasparKielwein 8b7b9627ed removed unused variables and outcommented code in freespace.cpp 2019-12-19 21:50:15 +01:00
Taylor Richards 7e2193ef2d avoid ending mission on death unless we should
should fix Mantis 2377 and probably several other issues
2019-12-18 09:55:15 -05:00
Taylor Richards f536b0cda2 fix Trails.next pointing to invalid address 2019-12-18 09:54:18 -05:00
Goober5000 58992cfd3a Merge pull request #2201 from MageKing17/bugfix/undinky-shockwaves
Make Dinky Shockwaves not dinky by default.
2019-12-17 02:50:20 -05:00
Goober5000 d9dfce3c25 Merge pull request #2147 from asarium/feature/luaParseObjects
Add Lua access to not yet arrived ships
2019-12-17 02:35:14 -05:00
MageKing17 440162ab24 Use a float multiplier instead of a boolean.
Also, I forgot to initialize the variable in mod_table_reset() before.
2019-12-16 21:43:21 -08:00
MageKing17 c9e38fedd2 Make Dinky Shockwaves not dinky by default.
Adds a new mod table option "$Default Dinky Shockwaves:" that toggles the behavior. See issue #774 for more information.
2019-12-16 17:46:27 -08:00
Goober5000 2856ae3583 Merge pull request #2197 from wookieejedi/update-fred-key-pressed-tree
Allow sexp-tree for `key-pressed` to actually show what the mod will use
2019-12-15 20:14:27 -05:00
Allen A. Babb bb2f19c176 Merge pull request #2198 from FSCyborg/Mark-VM_EXTERNAL_CAMERA_LOCK-Deprecated
Add deprecation warning for VM_EXTERNAL_CAMERA_LOCKED
2019-12-15 18:53:16 -06:00
FSCyborg d16a3fa5cf Add deprecation warning for VM_EXTERNAL_CAMERA_LOCKED
Previously deprecated enum for hasViewmode() lua function didn't have a warning.  This fixes that.

Also, I am adding a check to ignore it while writing scripting.hmtl.
2019-12-15 15:03:00 -05:00
wookieejedi b07a3282ad adjust position of function call 2019-12-15 14:50:34 -05:00
Goober5000 83370f6219 Merge pull request #2194 from wookieejedi/add-default-keys-custom-controls
Allows the custom controls to work with `key-pressed` sexp
2019-12-15 14:39:55 -05:00
asarium 3960af6ba5 Add Lua access to not yet arrived ships 2019-12-15 15:42:07 +01:00
wookieejedi b0edc12985 cleanup whitespace diff 2019-12-15 00:51:08 -05:00
wookieejedi 83c72ec9ae modify location and add to qtfred 2019-12-15 00:39:37 -05:00
Goober5000 d3c5eb3894 Merge pull request #2142 from notimaginative/auto_port_forwarding
Auto port forwarding
2019-12-14 23:51:03 -05:00
wookieejedi 82a53d8fef Allow sexp-tree for key-pressed to actually show what the mod will use
This PR allows modders/FREDers to actually see what default controls available are in FRED and not the hard coded ones from `Control_config` that may not be relevant for their mod. For example, a mod may disable many controls and change the default key for many controls in the table, but that is not reflected in FRED since FRED simply checks the hard coded ones from `Control_config`.

Example:
Previously, if the modder specifies a default key for, say, `Enter Subspace (End Mission)` as `Enter` instead of `Alt-J` in `Controlconfigdefaults.tbl` then the game will only look for if `Enter` was pressed, whereas the `key-pressed` tree in FRED will not show that and will still show `Alt-J`. Then if the FREDer uses `Alt-J` it won't ever actually trigger in-game since the control table has switched it to `Enter`. This PR would allow FRED to properly show `Enter` instead of `Alt-J` in the sexp tree for `key-pressed`.

Background:
1) Game reads the hardcoded values for each key and saves in `Control_config`
2) Game parses `Controlconfigdefaults.tbl` and updates the default keys in `Control_config` with any that are specified in that table.
3) Now the key defaults have been changed, and when `key-pressed` is called it searches for it's argument in the updated `Control_config` array, but only searches for the default. Thus even if the player changed the key, it will still find it and properly convert it.

All of that works well and as expected. But FRED never goes beyond step 1, so when FREDing I don't use the drop down tree for `key-pressed` since it doesn't actually match what the game will know when it parses `Controlconfigdefaults.tbl` in step 2.
2019-12-14 16:16:32 -05:00
wookieejedi 7d60ee882b add keys 0 and 5-9 2019-12-14 15:20:31 -05:00
Goober5000 f958116a64 Merge pull request #2190 from MitoPL/MitoPL-patch-1
Hide FPS counter with the rest of HUD
2019-12-14 15:05:32 -05:00
Goober5000 4b51ac5987 Merge pull request #2184 from FSCyborg/Fix-JumpNode-Briefing-Bug
Fix Crashes In Briefing Screen
2019-12-14 11:57:29 -05:00
Goober5000 d06a3ca72c Merge pull request #2195 from Goober5000/fix_mantis_2542
apply fix for model_anim_get_time_type (Mantis 2542)
2019-12-14 11:31:03 -05:00
m!m fdf37dcb35 Merge pull request #2052 from asarium/feature/scriptingModelPaths
Add scripting API support for model paths
2019-12-14 12:36:18 +01:00
asarium b825f57bf4 Add scripting API support for model paths
This adds a scripting API for querying the paths of a model.
2019-12-14 09:15:44 +01:00
Goober5000 d664f13f97 Merge pull request #2192 from FSCyborg/Fix_FSO_Launch_From_FRED
Open FSO from FRED Using FRED's Directory
2019-12-14 00:47:16 -05:00
Goober5000 a069eb62f9 apply fix for model_anim_get_time_type (Mantis 2542)
This patch was posted in 2011 but never applied.  Here's a PR to remedy that.

Mantis ticket:
http://scp.indiegames.us/mantis/view.php?id=2542

Original thread:
http://www.hard-light.net/forums/index.php?topic=79068.0
2019-12-14 00:39:58 -05:00
wookieejedi 3bc878db9a Allows the custom controls to work with key-pressed sexp
This expands the functionality of the cusotm controls to work with rebindings when using the sexp `key-pressed`. A key default value must be specified in `controlsconfigcommon.cpp` for the sexp `key-pressed` to track key binding changes. This PR adds that functionality by assigning default keys that were not in use (alt shift 1-5).
2019-12-13 23:27:35 -05:00
FSCyborg 0e31be10f5 Switch to nullptr in this function 2019-12-13 21:19:56 -05:00
Goober5000 e96f9400e1 Merge pull request #2193 from The-E/fix/remove_unused_cmdline_flags
Remove the -ogl_spec and -spec_exp cmdline arguments
2019-12-13 13:46:20 -05:00
Fabian Woltermann d703d61cba Remove the -ogl_spec and -spec_exp cmdline arguments, as they are no longer used by anything 2019-12-13 12:37:36 +01:00
FSCyborg f00be46211 Open FSO from FRED Using FRED's Directory
According to the CreateProcess() documentation, passing NULL in the eighth argument starts a process in the same directory as the original process, which is what we're trying to do.

Please note this is a Windows only solution, and cannot be ported to QTFred

Addresses 1775, already tested on Release and Debug
2019-12-12 21:36:18 -05:00
Taylor Richards 826a92745d clean up logging just a bit 2019-12-12 08:06:59 -05:00
Taylor Richards f573706d07 allow for unicast (gateway) route type
this fixes an issue where the default gateway
isn't in the main routing table but is instead
the primary unicast route

(ChromeOS, maybe others)
2019-12-12 08:06:59 -05:00
Taylor Richards 9ae62e9db8 remove some cruft from previous attempts 2019-12-12 08:06:59 -05:00
Taylor Richards 7da6276f07 fix type issue with XP compat code 2019-12-12 08:06:59 -05:00
Taylor Richards c286c4c2ce add support for automatic port forwarding 2019-12-12 08:06:59 -05:00
Goober5000 820d4452d8 Merge pull request #2191 from notimaginative/fix_multi_mode_switch
properly save single/multi mode setting
2019-12-12 03:07:16 -05:00
MitoPL e8a07b6972 Update freespace.cpp
A quick update that should allow for the FPS gauge to be hidden together with the rest of the HUD. Sounds useful for anyone wanting to take clean screenshots.
Also, thanks @wookiejedi for showing me how to do this.
(Will that even work? that's my first real meeting with GitHub so I'm a bit anxious.)
2019-12-12 01:19:34 +01:00
Taylor Richards 7ede543ca7 properly save single/multi mode setting 2019-12-11 17:48:48 -05:00
Goober5000 da1634cdc2 Merge pull request #2158 from Goober5000/never_viewable
add $Never Viewable flag for cutscenes
2019-12-11 12:49:59 -05:00
Goober5000 1183140dc2 Merge pull request #2169 from notimaginative/pxo_banners
fix PXO banners (and inetgetfile stuff)
2019-12-11 12:47:37 -05:00
Allen A. Babb fc29960b3b Merge pull request #2189 from wookieejedi/add-custom-controls-for-modders
Add Extra, Empty Controls for Modders to Use.
2019-12-11 07:59:10 -06:00
wookieejedi 2e3f0e2f80 Add Extra, Empty Controls for Modders to Use
Many mods and scripts use custom features that are triggered by key press. Currently, those keypresses cannot be changed by the player. I want to add 5 controls that do nothing and thus can be used for scripts/modding purposes. This way the modder could add new features/controls easily and have them show up in the controls menu and be bindable. As opposed to using a script which triggers via a keypress, and that keypress cannot be changed by the player in game (and may be bound to another control).

Also, Axem has expressed he would find this feature and Fate of the Galaxy certainly will.
2019-12-10 19:59:04 -05:00
Goober5000 d9bb6625fd Merge pull request #2188 from asarium/fix/1481
Fix #1481: Use a lower default specular factor
2019-12-10 19:07:12 -05:00
Goober5000 d2c9afc853 Merge pull request #2187 from wookieejedi/specify-string-index-via-xstr
Method to fix controls translation issue
2019-12-10 19:06:43 -05:00
wookieejedi 8535c3cbea clarify variable is int 2019-12-10 13:51:03 -05:00
wookieejedi 8fdd8624e4 fix struct issue 2019-12-10 13:44:21 -05:00
asarium c294433741 Fix #1481: Use a lower default specular factor
This is a fix for models with no spec map since the current default
factor looks very odd for retail models.
2019-12-10 19:40:18 +01:00
wookieejedi e89fb04b8c test fix troubleshooting 2019-12-10 13:24:52 -05:00
wookieejedi de0a43940f update comment with correct type 2019-12-10 13:20:28 -05:00
wookieejedi 02aab6cfdf Method to fix controls translation issue
This PR adds functionality to `Has Xstr:` in `controlconfiguredefaults.tbl`. Previously this value was use as a boolean, 0 or 1 to specify if the string should be used. This PR treats that field as an integer, and thus allows modders to specify which string to use for the control. If the value is 0 (default) then the string is not used, if the value is 1 then the defautl string is used and if the value is greater then 1 the game will use that specified index in strings.tbl.

This allows modders to properly translate all control names.  Specifially, six controls overlaped with pre-existing string.tbl indexes adn thus could not be translated properly. These are VIEW_TOPDOWN, VIEW_TRACK_TARGET, AUTO_PILOT_TOGGLE, NAV_CYCLE, TOGGLE_GLIDING, and CYCLE_PRIMARY_WEAPON_SEQUENCE.

This PR will allow modders to now proerly have full control name translations. It also provides a fix for issue #1629.
2019-12-10 12:57:31 -05:00
FSCyborg d0bee3a3ac Fix Crashes In Briefing Screen
Fixes the following:
1. Crash from creating an icon from a jumpnode
2. Crash from creating an icon from a waypoint
3. Waypoint would become a jumpnode icon in briefing screen.

This line is the cause:

                iconp->ship_class = (int)std::distance(Ship_info.cbegin(), it);

The main purpose of this commit is to change iconp to biconp, like the rest of the function uses.

The other change is how it checks for a jumpnode so that it is only true if there *is* a jumpnode.
2019-12-09 21:48:16 -05:00
Goober5000 2049778da8 Merge pull request #2171 from Kiloku/master
Add Documentation Update instructions and moves Building info from Readme to wiki
2019-12-09 16:19:43 -05:00
Goober5000 2972fdc1cf Merge pull request #2186 from wookieejedi/deprecate-set-object-speed
Deprecates `set-object-speed` in favor of `ship-maneuver`
2019-12-09 16:18:48 -05:00
wookieejedi b0dfca91c5 hide set-object-speed in FRED 2019-12-09 14:37:59 -05:00
wookieejedi 55e5351214 Deprecates set-object-position in favor of // wookieejedi - this sexp is deprecated in favor of ship-maneuver`
Per dicussion on Discord and and Github, `set-object-position`  does not work properly and the fix would involve making it act the same way as `ship-maneuver`. With discussions with Goober (who originally made it), we have decided to deprecate the sexp. I have talked with folks who have used it thus I am not removing it from FRED with this PR but I am open to discussion on that point.
2019-12-09 14:15:38 -05:00
MageKing17 2789d143bb Merge pull request #2185 from MageKing17/cleanup/objecttypes-nocreate-behavior
Standardize nonstandard "+nocreate" behavior in objecttypes.tbl
2019-12-09 01:31:40 -08:00
MageKing17 8935075af9 Make clang-tidy happy by changing NULL to nullptr. 2019-12-08 19:25:24 -08:00
MageKing17 90467f8f41 Standardize nonstandard "+nocreate" behavior in objecttypes.tbl
If you modified an existing ship type without using +nocreate, it would both modify it and add it to the vector again, leading to (at the very least) wasted memory. I copied over some more standard behavior from other parsing functions to hopefully avoid problems with modular objecttypes.
2019-12-08 18:53:19 -08:00
Goober5000 4d6ec5c431 Merge pull request #2182 from wookieejedi/fix-rtt-ss-bracket-bug
Fix RTT Subsystem Bracket Bug
2019-12-08 15:08:02 -05:00
wookieejedi 9184ed4224 Fix RTT Subsystem Bracket Bug
Previosuly, subsystem brackets in the target ship gauge were not always drawn in the correct location when using RTT with the gauge. This PR fixes that.
2019-12-07 23:56:54 -05:00
Goober5000 599313da81 Merge pull request #2179 from asarium/fix/ciStuff
Fix some CI issues
2019-12-07 11:26:58 -05:00
Goober5000andMageKing17 f8bdfa2d0b Update code/cutscene/cutscenes.cpp
Slightly compactify flag check

Co-Authored-By: MageKing17 <[email protected]>
2019-12-05 12:22:16 -05:00
asarium f817538567 Fix some CI issues
First one is to allow MinGW failures since that is unreliable at the
moment. Second one is a fix for the regex used by clang-tidy so that it
doesn't try to analyze CMake files.
2019-12-05 18:16:59 +01:00
Goober5000 8bde99654f Merge pull request #2178 from FSCyborg/Free_Look_X_Inversion_bug
Fix Free look turning in the wrong directions
2019-12-05 11:48:30 -05:00
Taylor Richards 7552b50a2e address clang-tidy issues 2019-12-05 01:30:18 -05:00
Taylor Richards f4883401e9 const all the chars 2019-12-05 01:30:18 -05:00
Taylor Richards d223aee4e7 fix PXO banners (and inetgetfile stuff) 2019-12-05 01:30:18 -05:00
FSCyborg d6ec51235b Fix Free look turning in the wrong directions
Free look will now move in the same directions as ship controls, whether pitch or yaw, and whether using keyboard or mouse/joystick.

Also, remove an inaccurate comment, and add a clarifying one.
2019-12-04 23:50:39 -05:00
Goober5000 d84231642d Merge pull request #2177 from MageKing17/bugfix/surround-front-speakers
Make 2D sounds play from front speakers instead of rear.
2019-12-04 22:14:14 -05:00
Goober5000 0f020abf3d use a flagset 2019-12-04 21:26:05 -05:00
MageKing17 39bd7cfdce Make 2D sounds play from front speakers instead of rear.
The Z coordinate, from negative to positive, means "front to back", so a Z value of 1.0 (with relative playback, which is what 2D sounds use) means "as far back as possible", i.e. the rear speakers. It's hard to know if this was intentional or not, but feedback from an actual user with a surround setup is that the opposite is preferable.
2019-12-04 17:10:23 -08:00
MageKing17 4cad3d4fc2 Merge pull request #2174 from Goober5000/repeat_count_fix
better sanity-checking for repeat_count, and also check trigger_count
2019-12-04 14:59:38 -08:00
Goober5000 0eb0cc87d1 correction 2019-12-04 00:57:02 -05:00
MageKing17 520f8f4e04 Merge pull request #2175 from Goober5000/fix_2063_bug
fix set-object-facing for wings not present
2019-12-02 23:05:46 -08:00
Goober5000 85e955a58f fix set-object-facing for wings not present
There was a small but serious bug in PR #2063 that would cause a crash.  This fixes it.
2019-12-02 23:36:28 -05:00
Goober5000 c01e30e393 address CI complaint 2019-12-02 23:09:03 -05:00
Goober5000 52f709a2db address feedback 2019-12-02 18:11:29 -05:00
Goober5000 425a6e67d5 add $Never Viewable flag for cutscenes
There are now three states for cutscenes: always viewable, where they will appear no matter what; never viewable, where they will never appear; and viewable, which can be modified during the campaign.  Currently cutscenes will go from not-viewable to viewable, but organizing the flags this way will allow a future feature to make cutscenes not-viewable, if that is desired.

There's also a small edit to csv_convert to guard against array overflows.  Not directly related to the feature but it's in the same place and affects the same code.
2019-12-02 18:11:29 -05:00
Goober5000 3c7c8486eb better sanity-checking for repeat_count, and also check trigger_count
Sanity checking for repeat counts shouldn't crash the game, so change from Error to Warning and use a sensible default.  Also copy the check (with minor modification) to also check trigger counts.
2019-12-02 17:56:51 -05:00
Goober5000 fadcaa0ca1 Merge pull request #2051 from asarium/feature/genericLuaDocumentation
Make Lua documentation generation more generic
2019-12-02 17:53:14 -05:00
Goober5000 e885203683 Revert "try this compiler flag, per https://stackoverflow.com/questions/43152633/invalid-register-for-seh-savexmm-in-cygwin"
This reverts commit 013f6007f3.
2019-12-02 16:05:04 -05:00
Goober5000 013f6007f3 try this compiler flag, per https://stackoverflow.com/questions/43152633/invalid-register-for-seh-savexmm-in-cygwin 2019-12-02 14:54:19 -05:00
Goober5000 65ced1279d change to nullptr 2019-12-02 10:20:15 -05:00
Goober5000 383b3b7ca9 Merge pull request #2163 from Goober5000/revisiting_1450
don't restart if we are switching to a previously finished campaign
2019-12-01 14:07:53 -05:00
Goober5000 8204de3854 Merge pull request #2172 from wookieejedi/fix-on-goals-cleared
Fix FRED not working
2019-12-01 14:06:27 -05:00
Goober5000 c4a7a234ae Merge branch 'master' into feature/genericLuaDocumentation 2019-12-01 14:01:09 -05:00
Goober5000 8808e26f06 Merge pull request #2170 from Goober5000/small_fixes
Two small fixes
2019-12-01 13:57:30 -05:00
wookieejedi 10150c0640 fix int return 2019-12-01 12:07:44 -05:00
wookieejedi 674b6cd4fb Adds valid scripting state checks to functions that it was missing in 2019-12-01 11:59:15 -05:00
wookieejedi d271e33cca Fix fred not working
The `On Goals Cleared` scripting hook would result in FRED not working, thus this PR adds a check for scripting state to the hook and will only run if the scripting state is active. Now FRED will run proprerly.
2019-12-01 11:32:30 -05:00
Kiloku d340d96202 Formatting fixes 2019-12-01 09:58:53 -02:00
asarium 4ca589a61c Make Lua documentation generation more generic
This adds JSON as an additional scripting documentation output format.
This can be used by external tools to examine the scripting
documentation and generate interface declarations or documentation for
any language. The existing documentation code is left largely in place.
2019-12-01 12:53:51 +01:00
Kiloku 4ae495437b Moved most of the Readme to the wiki and linked it 2019-12-01 09:51:31 -02:00
Goober5000 8ed68efc34 Merge pull request #2154 from FSCyborg/Fix-sexp-set-weapon
Keep set-secondary-weapon from using nonsense
2019-12-01 00:37:30 -05:00
Goober5000 1a8dcb1be9 maybe this instead 2019-12-01 00:35:36 -05:00
Goober5000 821f90c5db add explicit cast to fix CI warning 2019-11-30 23:01:02 -05:00
Goober5000 775359c636 Merge pull request #2168 from notimaginative/multi_config_pxo
sanitize parsed multi.cfg settings for PXO
2019-11-30 22:59:23 -05:00
Goober5000 2d7c4de268 set Shadow_quality to default value 2019-11-30 22:55:20 -05:00
Goober5000 16b4c36cc0 Merge pull request #2167 from wookieejedi/fix-get-pitch-from-matrix
Fixes the extraction of pitch
2019-11-30 21:45:01 -05:00
FSCyborg 0008c5bacb Keeps set-secondary-weapon from using nonsense
Set-secondary-weapon and set-secondary-ammo have been up to know been allowed to exceed tabled cargo sizes, as long as you didn't put a value for requested_ammo in the sexp.

The limits would be inherited from the last secondary weapon in the slot, definitely not idea behavior.

Now includes matching changes to set-primary-ammo
2019-11-30 15:58:11 -05:00
Taylor Richards f518e277f1 sanitize parsed multi.cfg settings for PXO 2019-11-30 15:32:13 -05:00
Goober5000 0ff32b3f3e Merge pull request #2146 from scp-fs2open/feature/1587-new_lighting_defaults
Makes slight adjustments to the lighting defaults.
2019-11-30 12:57:54 -05:00
Fabian Woltermann 6abd8b0b60 Change the link associated with the -emissive_light flag 2019-11-30 15:02:21 +01:00
Goober5000 903e1563ce Merge pull request #2164 from FSCyborg/Mission_Campaign_Duplicate
Only Try To Load a Campaign Once
2019-11-29 17:51:02 -05:00
wookieejedi e519646e28 Optimized a bit
Tried a few different things and still can't find a way to remove the square-root unforuntealy.
2019-11-29 17:49:22 -05:00
Goober5000 4f89dd3c2f Merge pull request #2165 from chief1983/fix/line_ending_tomfoolery
Fix Line Ending Tomfoolery
2019-11-29 17:48:30 -05:00
wookieejedi 48773e3099 Fixes the extraction of pitch
It turns out that `angles_2_matrix ` would return a pitch value that was not the actual pitch from the 3x3 matrix. The pitch line in the code is uses a modifed `cosp` as the demoninator to calculate the pitch angle. I looked up online what the caclulation should be and found a more accurate way than using the modifed cosp, is to use ( fvec.xyz.x^2 + fvec.xyz.z^2 )^0.5 I tested using the new calculation throughouly and in each test it returned the proper pitch value from the 3x3 orientation matrix.
2019-11-29 16:31:41 -05:00
Cliff 5f234426b1 fix/line_ending_tomfoolery: Making everything auto globally is causing more problems than it might be trying to solve. 2019-11-29 10:40:08 -06:00
FSCyborg 7b2e8340c6 Only Try To Load a Campaign Once
Correct me if I'm wrong, but there's no need to try to load the default campaign twice.
2019-11-29 00:50:40 -05:00
Goober5000 1d4dea29d1 Merge pull request #2162 from Goober5000/small_play_sound_fix
very small fix to multi_sexp_close_sound_from_file
2019-11-29 00:29:02 -05: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 c5ae4ca2b9 very small fix to multi_sexp_close_sound_from_file
The default fade argument is `true`, as specified by the sexp help, not false.  This probably doesn't matter here as the multi packet should receive all sexp arguments anyway, but better to be consistent.
2019-11-28 13:00:21 -05:00
Goober5000 9abcd55f23 Merge pull request #2159 from wookieejedi/add-on-goals-cleared-hook
Add `On Goals Cleared` Scripting Hook
2019-11-28 12:00:33 -05:00
Kiloku 88fdae1863 Merge branch 'master' of https://github.com/Kiloku/fs2open.github.com 2019-11-28 00:30:44 -02:00
Kiloku 4c9454274f Merge pull request #1 from scp-fs2open/master
Updating
2019-11-27 23:30:09 -03:00
Kiloku 4fc13dcb72 Added a bit more info to the checklist 2019-11-28 00:11:09 -02:00
Kiloku ceb592b182 Added a simple checklist to help keep the documentation updated 2019-11-28 00:05:23 -02:00
Goober5000 54455522b2 Merge pull request #2156 from Kiloku/master
Tackles most of #711
2019-11-26 22:24:30 -05:00
wookieejedi ea021c6fe3 Add On Goals Cleared Scripting Hook
Adds 'On Goals Cleared' hook variable for scripting system. Previosly there was not scripting or sexp method to determine if a ship had all of it's goals cleared.
2019-11-25 21:12:40 -05:00
Goober5000 ccb7480b53 Merge pull request #2155 from wookieejedi/improve-on-waypoints-done-hook
Add waypoint-path hook variable to `On Waypoints Done` Hook
2019-11-25 00:47:08 -05:00
wookieejedi 06a783cce4 Use more consistent naming with Waypointlist 2019-11-24 23:11:23 -05:00
wookieejedi d56ce4cb56 add missing space 2019-11-24 21:13:56 -05:00
wookieejedi a93be36740 simplify waypointpath set 2019-11-24 18:17:37 -05:00
wookieejedi 3926ee39dd Add waypoint path name to On Waypoints Done Hook
Originall the scripting hook `On Waypoints Done` only provided the ship or wing. This PR adds the waypoint path that was completed as an additional hook variable.
2019-11-24 15:16:11 -05:00
Kiloku 44c9fc2ec9 Corrected formatting in Copying.md 2019-11-24 18:13:42 -02:00
Kiloku b06f6476c9 Add youtube link 2019-11-24 18:12:12 -02:00
Kiloku 8278007cdb Merge branch 'master' of https://github.com/Kiloku/fs2open.github.com 2019-11-24 18:09:55 -02:00
Kiloku c5d201ba67 Linked updated video (1999/2019) and reworded comparison line 2019-11-24 18:09:37 -02:00
Kiloku 30326cb67e Rename COPYING.md to Copying.md 2019-11-24 17:07:13 -03:00
Kiloku d4c960fa13 Added FSU comparison video link to About.md 2019-11-24 18:05:49 -02:00
Kiloku 78c7f375cc Remove FS2OpenSCPReadMe.doc file, which was severely outdated. 2019-11-24 17:59:21 -02:00
Kiloku 851899418e Add About.md file, giving general information meant more for newcomers 2019-11-24 17:58:40 -02:00
Kiloku 58bd966f54 Removed outdated INSTALL file 2019-11-24 17:27:20 -02:00
Kiloku 5dbefc99d0 Changed Authors to a markdown file, updated the information in it 2019-11-24 17:27:09 -02:00
Kiloku d60929cd53 Changed COPYING to MarkDown format, added a link to the FSO's Licensing page at wiki in github 2019-11-24 17:13:39 -02:00
Kiloku fdca5ffeed Added a separator before the Older Changes section 2019-11-24 17:08:03 -02:00
Kiloku 9ac5c7e041 Minor formatting change 2019-11-24 17:07:11 -02:00
Kiloku 75d925e8e8 Re-ordered the sections in 3.6.14 2019-11-24 17:05:04 -02:00
Kiloku bec81ed752 Merged old changelog into the new changelog 2019-11-24 17:03:18 -02:00
Kiloku 0a61706368 Added links to some relevant info and added a section explaining the version number scheme change 2019-11-24 16:59:25 -02:00
Kiloku 368194a23e Added more changes found through some extra sleuthing 2019-11-24 16:54:10 -02:00
Kiloku ff520dbfa4 Added changes all the way to 3.6.14 (2012) 2019-11-24 16:46:06 -02:00
Kiloku e2c6fc3cc2 Increased conformity with Keep A Changelog 2019-11-24 15:54:18 -02:00
Kiloku 6d770c8bc5 Added 2019 RC1 to changelog 2019-11-24 15:44:02 -02:00
Goober5000 6200b380d7 Merge pull request #2144 from notimaginative/winsock2
switch to using winsock2
2019-11-23 09:25:11 -05:00
Goober5000 ea7c454e6a Merge pull request #2149 from FSCyborg/Patch_N-Gon_Radar
Patch n gon radar
2019-11-23 09:23:57 -05:00
Fabian Woltermann 7d40cbb241 Merge pull request #2148 from notimaginative/fix_audiostr_looping
avoid full stream reset when looping music
2019-11-23 11:32:00 +01:00
Fabian Woltermann 6c356692b2 Merge pull request #2152 from FSCyborg/Fix-The-Pirates
Bring Pirates of the FSO Back by
2019-11-23 11:30:18 +01:00
Fabian Woltermann 400440ca63 Merge pull request #2153 from FSCyborg/Fix-1992
Fix#1992
2019-11-23 11:27:56 +01:00
Fabian Woltermann 5ae9623f9e Switches the behaviour of the Lab emissive lighting switch to be in line with the other changes. 2019-11-23 11:06:38 +01:00
Goober5000 166a88d4a6 Merge pull request #2139 from FSCyborg/Fix#1886
Fix#1886 by Upgrading to SDL 2.0.10
2019-11-22 20:25:21 -05:00
Taylor Richards 0dcea8f93e fix building of qtFRED 2019-11-20 22:57:41 -05:00
FSCyborg 4c2a3450f8 Fix 1992
Send the ship to the actual initial position once the engine knows where the ship should end up.
2019-11-18 22:16:33 -05:00
FSCyborg 51d362e447 Bring Pirates of the FSO Back by
Preventing a nullptr deep within shipfx_warpin_start()

Add Assertions to check for nullptr Warp Effect
2019-11-18 21:40:16 -05:00
Taylor Richards 70b14a5c2c fix PORT command
was in wrong order before, did this code
ever work? ...
2019-11-18 17:04:02 -05:00
Taylor Richards e9cf9ac10d deal with type warnings on Windows 2019-11-18 12:00:26 -05:00
Taylor Richards 990820cad8 prevent excess headers being included on Windows 2019-11-18 11:59:19 -05:00
FSCyborg 623be80e48 Move Creation of Hud Gauge to Accomodate gauge_load_common()
We didn't realize that Gauge_load_common had some assumptions about where Origin: and Offset: are, so we accidentally broke custom radars.  Moving this section up forces modders to have an odd order for their entries, but based on the way the code was written, there really doesn't seem to be another choice.
2019-11-17 21:22:22 -05:00
Taylor Richards 6b3f5051ea avoid full stream reset when looping music
fixes #2097
2019-11-17 16:00:38 -05:00
Fabian Woltermann 7451fb36d9 Actually set the bloom intensity 2019-11-17 18:07:33 +01:00
Fabian 9e5cd347be Makes slight adjustments to the lighting defaults.
This commit disables emissive lighting on objects by default (as the new HDR process makes it unnecessary) and switches the -no-emissive commandline parameter to -emissive; Setting that parameter will restore the old behaviour. The -no-emissive parameter is retained to avoid user-facing error messages.
In addition, this commit sets the default bloom value to 25.
2019-11-17 13:38:24 +01:00
FSCyborg 1f41d98e2a Fix#1886 by Upgrading to SDL 2.0.10
This should fix #1886.  I built it and it fixes the immediate problem.

Only two of the documentation files we have in the codebase were actually updated.

Verison name in prebuilt.cmake also needed to be changed due to prebuild SDL version changing during upgrade to the prebuild repository.
2019-11-16 16:39:12 -05:00
Goober5000 1c77ffe07f Merge pull request #1211 from z64555/feature/ngon_radar_vector
[Feature] Ngon Radar
2019-11-16 14:46:43 -05:00
Goober5000 29b853de0c Merge pull request #2028 from Goober5000/clang_tidy_upgrade
upgrade clang-tidy to 8.0, the latest stable release
2019-11-16 13:53:35 -05:00
Goober5000 48c67b563a Merge pull request #2145 from asarium/fix/referenceNullError
Handle invalid Lua reference correctly
2019-11-16 13:52:28 -05:00
asarium 4ccccb526e Upgrade Travis to Xenial to support newer clang-tidy versions 2019-11-16 17:11:57 +01:00
asarium a61324f559 Handle invalid Lua reference correctly
This should never have worked but was only discovered by the recent
switch to the default copy constructors for some reason.
2019-11-16 17:08:34 +01:00
Goober5000 a3d2ca5724 add additional configuration per github comments 2019-11-16 15:46:05 +01:00
Goober5000 97ace6fa8c upgrade clang-tidy to 8.0, the latest stable release 2019-11-16 15:46:05 +01:00
m!m 7a11e247f3 Merge pull request #1740 from asarium/build/clangXstrFinder
Add tool for extracting XSTR calls
2019-11-16 15:36:43 +01:00
Taylor Richards 29ce72f66f switch to using winsock2
also removes some obsolete win32 #ifdef's and
cleans up some windows #include's
2019-11-15 23:33:35 -05:00
Goober5000 a94c4e46a1 Merge pull request #2136 from FSCyborg/dumb_rotate
Fix Dumb_Rotate Regression
2019-11-13 01:15:12 -05:00
Goober5000 e262878add Merge pull request #2143 from wookieejedi/fix_3d_weaponselect
Fixes 3D Weapon Selection Bug
2019-11-12 23:06:57 -05:00
wookieejedi c499cfb192 Fixes 3D Weapon Selection Bug
Fixes 3D weapon selection not working when an animation is already specified.
2019-11-12 21:34:20 -05:00
FSCyborg 2238c0af63 Move Default Values to Class Define
Part of modernizing the code base, Travis, at least, prefers defaults to be in the class definition instead of having multiple constructor functions have the same default values.
2019-11-12 16:58:41 -05:00
Goober5000 6a0023da4b Merge pull request #2141 from FSCyborg/fix_rearm_increment
Set Ballistic Primaries ream increment no matter what
2019-11-11 15:52:43 -05:00
FSCyborg bb19d69b7b Set Ballistic Primaries if not Missiles no matter what
Fix the rearm by not depending on flags that haven't been set yet....
2019-11-11 12:39:20 -05:00
FSCyborg e62b64bac8 Fix Dumb_Rotate Regression
Allows jump nodes to use instrinsic/dumb rotation again by exposing the jump node class to the model instancing code and adding a check for it in modelread.
2019-11-11 11:22:13 -05:00
FSCyborg a17f5031bf Fix the unique pointer and constructor
Unique pointers need to be constructed in very particular ways, but so did this NGON radar class, so we just had to put the constructor function inside unique pointer constructor.

And to keep that special pointer from going out of scope, we switched to the ternery operator.

Also made these changes:
Change to hypotf()
Fix Shadowing, Zero Vector macro not working at all.
Offset changed to offset_incoming
blip changed to blip_instance
Offset changed to = {} to initialize the struct without a problem.
clampBlip() required an override
Give offset a default initializer.
Switch to <cmath>
(Apparently <math.h> was deprecated and needs to be replaced with <cmath>.)
One last complaint from travis about a redundant default value.

Thank you Travis!
2019-11-10 13:49:31 -05:00
z64555 1fb194a729 Use vmd_zero_vector instead of ZERO_VECTOR in places that expect an actual vector.
Refactor plotBlip() a bit.
Rename the variable 'blip' in clampBlip() to the more generic 'b'
Use 'hypotf' instead of '_hypotf'
2019-11-10 13:49:30 -05:00
z64555 f0f72b25a5 Add the ngon source files so cmake can find them. Update doxy of find_intersection. 2019-11-10 13:49:29 -05:00
z64555 f8f9bce7da Adds Ngon radar. This is a standard 2D radar, but uses a polygonal plot area instead of the std's oval.
* Modders can specify how many sides the radar can have (as few as 3) with "Ngon Sides:" and can also define an optional twist angle with "Ngon Offset:".

* Also refactors the standard radar code a bit
2019-11-10 13:49:28 -05:00
z64555 082304a4b8 Adds function to find the intersection of two lines 2019-11-10 13:49:27 -05:00
Goober5000 6614b6cd9a Merge pull request #2138 from notimaginative/fix_std_user_config_reset
fix standalone causing user config reset on *nix
2019-11-10 13:45:13 -05:00
Goober5000 3450a39e75 Merge pull request #2137 from notimaginative/fix_pxo_std_mod_detect
init tracker when attempting to validate game data
2019-11-10 13:44:30 -05:00
Taylor Richards 58ada6cf05 fix standalone causing user config reset on *nix 2019-11-10 00:47:02 -05:00
Taylor Richards 4369f1b555 init tracker when attempting to validate game data 2019-11-09 19:43:28 -05:00
Goober5000 8e94880c7f Merge pull request #2135 from Goober5000/goal_achievable_tweak
Two subsystem-related fixes
2019-11-08 16:06:10 -05:00
Goober5000 0a1bd5be5c Merge pull request #2127 from notimaginative/pxo
replace FS2NetD with PXO
2019-11-08 10:16:32 -05:00
Taylor Richards bd9880bc9b replace FS2NetD with PXO 2019-11-08 02:07:14 -05:00
Goober5000 6433181607 correctly set and recalculate subsystem info when using subsys-set-random 2019-11-07 19:20:25 -05:00
Goober5000 28ce16ba6b make goal-achievable dependent on actual status of subsystem 2019-11-07 19:19:51 -05:00
Goober5000 1b69015b50 Merge pull request #2129 from asarium/build/gcc9
Update Travis to GCC 9 and fix warnings
2019-11-07 15:36:34 -05:00
asarium be24f7f574 Switch back to int 2019-11-07 18:45:09 +01:00
asarium afc7c671d2 Remove Mac actions again
This fails for some obscure reason right after merging it. I don't care
enough about Mac to attempt to fix it so I'll just remove it...
2019-11-07 18:40:03 +01:00
asarium e31e68cba0 Update Travis to GCC 9 and fix warnings
Only one warning type this time, the implicit copy operator for types
with a copy constructor has been deprecated so we need to delcare them
ourself.
2019-11-06 18:22:50 +01:00
m!m b5663cfd89 Merge pull request #2134 from asarium/build/ghActions
Add Mac GitHub Actions
2019-11-05 18:44:15 +01:00
Goober5000 3ec94338d3 Merge pull request #2132 from FSCyborg/Coverity1370825
Coverity1370825
2019-11-04 22:51:05 -05:00
FSCyborg 627294039f Coverity1370825
Covertity is complaining about portions of the verts array being uninitialized, so this is just a quick change to initialize the array first before doing anything else.
2019-11-04 20:13:36 -05:00
Kiloku 86a12c0654 Initial changelog improvement 2019-11-04 21:41:41 -02:00
Goober5000 c5805bcd8d Merge pull request #2131 from FSCyborg/Covertiy-1297186,187,188,190
Address Coverity 1297186,187,188, 190
2019-11-03 20:27:46 -05:00
FSCyborg 601fa75d50 Change while(0) to while(false)
Travis is complaining about while(0), so we're getting it off of our back by switching to while(false).
2019-11-03 16:27:23 -05:00
Goober5000 68df93ccff Merge pull request #2130 from Goober5000/fix_missionnotes_flags
add missing lines for flags
2019-11-03 10:15:40 -05:00
FSCyborg 5084fdd189 Address Coverity 1297186,187,188, 190
These coverity issues are all caused by the same code being copy and pasted in three different places.

There does not seem to be danger of the negative array access, but the changes that "fix" it are also slight optimizations (assuming the compiler hasn't been catching them).

In short, I am basically just moving code around to avoid duiplicate checks and in other places checking for the negative array index explicitly.

Suggested style corrections now included.
2019-11-03 09:37:27 -05:00
asarium 256e5028a1 Add tool for extracting XSTR calls
This uses clangs LibTooling for parsing the FSO source files to ASTs
which can then be used for extracing the strings used in XSTR calls.
This supports both standard XSTR calls and UI_XSTR definitions and
writes the resulting information in the strings.tbl format to stdout.
It also detects duplicate translation id usages with different text
values.
2019-11-03 15:17:05 +01:00
asarium 327ee0fccb Add Mac GitHub Actions
Also separate windows tests into it's own step.
2019-11-03 13:09:30 +01:00
Goober5000 efb3d08494 add missing lines for flags 2019-11-02 00:28:45 -04:00
Allen A. Babb 2e5da03e86 Merge pull request #2128 from Goober5000/backwards_maneuver_fix
fix an oversight with dont-clamp-max-velocity
2019-10-31 10:53:18 -05:00
Goober5000 3a4bd86153 fix an oversight with dont-clamp-max-velocity 2019-10-29 19:59:53 -04:00
Goober5000 f0526e3f7c Merge pull request #2126 from asarium/build/ghActions
Add Windows Checks for GitHub Actions
2019-10-26 21:16:45 -04:00
asarium 963db03f3e Add Windows Checks for GitHub Actions
This will test compilation and tests on Windows as compiled by Visual
Studio and MinGW.
2019-10-26 22:23:48 +02:00
Goober5000 a8cf7f2c69 Merge pull request #2118 from Goober5000/maneuver_flags
Enhanced ship maneuvers
2019-10-26 14:10:40 -04:00
Goober5000 99c23b11cd Merge pull request #2115 from Goober5000/play_sound_from_file_improvements
allow multiple simultaneous sexp-controlled audio streams
2019-10-26 14:09:25 -04:00
Goober5000 8b7e99c4cb Merge pull request #2122 from Goober5000/small_sexp_h_fix
add OP_NONCAMPAIGN_FLAG to a couple sexps
2019-10-26 14:09:14 -04:00
Goober5000 515b0062f4 Merge pull request #2125 from Goober5000/matrix_from_vectors
create matrixes from vectors
2019-10-26 14:08:58 -04:00
Goober5000 ae1e0c90fa address feedback 2019-10-26 11:47:13 -04:00
MageKing17 edad20d562 Merge pull request #2121 from FSCyborg/fix-2120
Fix-2120
2019-10-25 19:15:30 -07:00
MageKing17 481be44713 Merge pull request #2076 from FSCyborg/#1848-Ballistic-Rearm_Time
For Issue #1848 - Add option to change default rearm values
2019-10-25 19:10:12 -07:00
Goober5000 d3c2b17ae9 actually this is correct 2019-10-25 15:01:02 -04:00
m!m f34e76bd55 Merge pull request #2123 from asarium/build/ghActions
Add more GitHub actions configurations
2019-10-25 19:57:53 +02:00
Goober5000 8a388accec create matrixes from vectors 2019-10-25 01:12:10 -04:00
asarium 8379a5c1f5 Add more GitHub actions configurations
This adds more Linux configurations for testing different compilers.
2019-10-24 20:33:54 +02:00
FSCyborg aef0e1f78a For Issue #1848 - Add option to change default rearm values
Although not technically a bug, several mods have been misled by the description of the "$Rearm Rate:" weapons table setting, and specifying an initial ammo value that is less than 100 for ballistic primaries would force the ballistic ammo to be loaded all at once, with "$Rearm Rate:" just specifying how long that one load would take.

This allows modders to use more realistic behavior for things like anti-turret ballistic primaries, where initial ammo could be in the thirties so that any number above zero can be added per load.
2019-10-24 01:10:52 -04:00
FSCyborg 4eac2e0cbc Fix-2120
Move the bottom text reset to inside the if so that it isn't kept empty by accident.

Let me know if I should move the comment around at all.
2019-10-23 23:26:15 -04:00
m!m 404c11e4a5 Merge pull request #2119 from asarium/fix/luaObjectHooks
Clear object events when Lua state is shut down
2019-10-23 18:18:22 +02:00
Goober5000 fc3ae5f93d add OP_NONCAMPAIGN_FLAG to a couple sexps that shouldn't be used in campaign files 2019-10-22 19:57:42 -04:00
asarium 0649f9abaa Clear object events when Lua state is shut down
Since the Lua state is destroyed before all the object events, this was
causing issues. This should fix that by clearing the events when the lua
state is destroyed.
2019-10-22 18:09:57 +02:00
m!m 17c9547d83 Merge pull request #2117 from asarium/build/ghActions
Add GitHub Actions workflow for pull requests
2019-10-21 18:12:00 +02:00
Goober5000 5f8192d1ee actually figure out instantaneous acceleration, and refactor a bit 2019-10-20 16:30:38 -04:00
Goober5000 2bea31dab0 Merge pull request #2116 from asarium/fix/2086-detect_unsupported_pref_chars
Fix #2086: Detect unsupported characters in root paths
2019-10-20 12:38:21 -04:00
asarium a22ef2e19d Add GitHub Actions workflow for pull requests
This currently only does the GCC Linux compilation but it's a good start
to check out how this works and if it will work for us.
2019-10-20 15:06:24 +02:00
asarium cf8fa26187 Fix #2086: Detect unsupported characters in root paths
Since FSO does not support Unicode characters in filesystem paths on
Windows yet, it is necessary to catch these issues early on and display
an appropriate error message. These changes do that by going through the
path with our UTF-8 decoder and detecting any characters that are out of
the ASCII range.
2019-10-20 12:46:00 +02:00
Goober5000 ab3388f397 add sexp and script support for maneuvers with new CIF_ flags 2019-10-20 00:59:43 -04:00
Goober5000 a80e4ba56e add some very useful control flags for ship maneuvers 2019-10-19 00:28:52 -04:00
Goober5000 3a9855ac69 allow multiple simultaneous sexp-controlled audio streams
Enhances play-sound-from-file, etc. to allow more than one audio stream to be played at the same time, provided all stream are referenced by audio handles contained in variables.
2019-10-18 23:23:00 -04:00
MageKing17 cced7e9e3f Merge pull request #2114 from MageKing17/cleanup/misc-typos
Correcting a couple debug typos.
2019-10-17 20:37:10 -07:00
MageKing17 323debfb91 Merge pull request #2113 from MageKing17/cleanup/png-warnings
Give PNG warnings their own category, so they're hidden by default.
2019-10-17 20:10:46 -07:00
MageKing17 4a464b2e8e Merge pull request #2112 from MageKing17/bugfix/csg-radar-range-check
Make .csg loading code check rp_dist, just like .plr loading does.
2019-10-17 20:10:34 -07:00
MageKing17 7a0a9ea475 Merge pull request #2111 from MageKing17/bugfix/filesystem-sort-order
Move filename sort in cf_get_file_list() to before packfile search.
2019-10-17 19:48:59 -07:00
MageKing17 8f619871e6 Move filename sort in cf_get_file_list() to before packfile search.
The intent behind this sort (added in #2094) was to make the order of files returned by the filesystem consistent across platforms; however, the sort occurred not only after the filesystem search, but after the packfile search, which changed the order files load in on all filesystems instead of making it consistent. This moves the sort to be after the filesystem search but before the packfile search, hopefully making load order consistent once more.
2019-10-17 14:14:31 -07:00
MageKing17 52fdb393ae Give PNG warnings their own category, so they're hidden by default.
This probably isn't the kind of information that should appear in the average debug log, since it's unlikely to be of use in standard troubleshooting.
2019-10-17 13:44:02 -07:00
MageKing17 9770d7f59b Make .csg loading code check rp_dist, just like .plr loading does.
When loading a .plr file, HUD_config.rp_dist is loaded and then sanity-checked; if the value is out of bounds, a Warning is generated and RR_INFINITY assigned. HUD_config.rp_dist is also loaded when loading a .csg file, however the sanity check isn't present; this copies the block over so the behavior is identical.
2019-10-17 13:41:12 -07:00
MageKing17 c1e6aca72b Correcting a couple debug typos.
"glowpoint present" should be "glowpoint preset", and there is no "op_num function".
2019-10-17 13:38:11 -07:00
MageKing17 40d3f5d38f Merge pull request #2110 from Goober5000/copy_text_until_errormsg_fix
fix bug in copy_text_until error message
2019-10-17 11:14:01 -07:00
Goober5000 58a4825d9b fix bug in copy_text_until error message
This bug has been around since the original public source code release!

The error message character calculation did not agree with the actual error check.  This PR fixes that.  Thanks to Novachen on Discord for discovering this.
2019-10-15 14:21:22 -04:00
Goober5000 3811eafee6 Merge pull request #2107 from Goober5000/fix_1138
fix FreeBSD warning in stubs.cpp
2019-10-14 00:56:03 -04:00
Goober5000 7703b27e64 Merge pull request #2105 from Goober5000/grant_medal_xstr
miscellaneous XSTR cleanup
2019-10-14 00:55:56 -04:00
Goober5000 18e9746792 formatting tweak, mainly to try to get the builds to trigger 2019-10-13 15:58:15 -04:00
Goober5000 334f392eb1 change token string, per m!m's review 2019-10-13 13:50:37 -04:00
Goober5000 d3d6e2ea41 add informative comment 2019-10-13 13:44:28 -04:00
Goober5000 db1da25272 Merge pull request #2100 from Goober5000/fix_2099
Handle pausing and unpausing music in certain screens
2019-10-13 13:37:11 -04:00
Goober5000 01102e14be Merge pull request #2102 from Goober5000/fix_for_counter
fix default loop increment in for-counter
2019-10-13 13:36:06 -04:00
Goober5000 2be44008da Merge pull request #2104 from Goober5000/fix_issue_1221
fix issue #1221
2019-10-13 13:35:00 -04:00
Goober5000 93effdd31b Merge pull request #2106 from Goober5000/command_sender_enhancement
implement Mantis 3204
2019-10-13 13:30:17 -04:00
Goober5000 aa2cc618d3 Merge pull request #2108 from Goober5000/arrival_departure_pr_from_595
Only update arrival/departure location if ship is not part of a wing
2019-10-13 13:28:04 -04:00
Goober5000 a5d63654fc Merge pull request #2103 from Goober5000/persistent_variable_errormsg_fix
this error message should report the variable name
2019-10-13 13:26:41 -04:00
Goober5000 09f1de6efe ohcomeon.gif 2019-10-12 16:21:09 -04:00
Goober5000 b4a4d70ff4 additional change suggested by MageKing17 2019-10-12 14:33:58 -04:00
Goober5000 c6c2e5b17e add the changes from downwash's PR 2019-10-12 14:25:00 -04:00
Goober5000 15c9533089 Merge pull request #1540 from z64555/enchancement/parse_bookmarks
Extends the existing parse pausing system (used by bmpman) to use a
2019-10-12 13:17:47 -04:00
Goober5000 2de323eb5d fix const conflict 2019-10-12 13:12:41 -04:00
Goober5000 2f00b3a081 fix FreeBSD warning in stubs.cpp
Use m!m's suggestion to fix issue #1138
2019-10-12 13:04:04 -04:00
Goober5000 6895276aea implement Mantis 3204
This adds a mission flag to use the Command Sender as the source of any messages sent from #Command.
2019-10-12 12:53:09 -04:00
Goober5000 ff31bebc9c now CTEXT will never be NULL 2019-10-12 11:46:57 -04:00
Goober5000 6006670439 restore the original grant-medal and was-medal-granted sexps 2019-10-12 11:27:32 -04:00
Goober5000 e91ee3dd4f the variable can never be uninitialized here, but Travis is too dumb to realize it 2019-10-12 01:26:11 -04:00
Goober5000 53ec0d45cb this isn't actually needed 2019-10-11 23:51:18 -04:00
Goober5000 a34d696c29 add xstr capability for medals
The grant-medal and was-medal-granted sexps will now translate medal names, in the same way that tech-add-intel-xstr translates intel entries.  There is also some minor cleanup and the specifying of correct default -1 numbers for the xstr-capable sexps.
2019-10-11 21:51:16 -04:00
Goober5000 ce57c52faf fix issue #1221
Make -get_flags imply -parse_cmdline_only, per asarium's comment
2019-10-11 16:56:06 -04:00
Goober5000 0db66e776a this error message should report the variable name 2019-10-11 01:22:22 -04:00
Goober5000 f9e4a4bb2a fix default loop increment in for-counter
The default loop increment is 1, not 0.  When for-counter was converted to use eval_nums in PR #2035, this was inadvertently broken.
2019-10-11 01:17:31 -04:00
Goober5000 8cb39c424b properly resume music; also properly restore subspace ambient sound 2019-10-08 22:57:29 -04:00
Goober5000 15346dad16 reactivate old code to pause and unpause audio, but this time add the proper check 2019-10-08 22:44:56 -04:00
Goober5000 de501fb3f1 pause and unpause the event music in the ESC dialog, just like we do in the pause screen, and just like the subspace sound was fixed 2019-10-08 22:20:46 -04:00
m!m 81a827dda9 Merge pull request #2094 from tcrayford/fix_modular_table_load_order_on_non_windows
fix modular table loading errors on non windows
2019-09-13 20:09:06 +02:00
Tom Crayford f7f537ff77 fix mod loading errors on non windows
When running a mod on non-windows, that isn't packed into VP files, the
mod can break when loading. On non-windows filesystems, the file
order isn't guaranteed to be alphabetical (but it is on Windows).
As a result, we load tables in an effectively random order.

Lots of mods rely on the filesystem ordering to e.g. implement a very
loose dependency system for their lua scripts.

Referenced on the forum here:
https://www.hard-light.net/forums/index.php?topic=95750.msg1885275#msg1885275

Here's a log from Solaris failing to run:

https://fsnebula.org/log/5d7b4414cb0d332b466b5ee2#True-138

Instead, always sort filesystem listing by name *before* applying the
provided sort order.

I've built a few different versions of this patch, and like this one the
best. The other ones I tried:
1. Adding a `CF_SORT_REVERSE_NAME` and using it everywhere that
`CF_SORT_REVERSE` is used, and replacing all uses of `CF_SORT_NONE` with
`CF_SORT_NAME`. I didn't like this as it was a much larger diff.
2. Adding a `CF_SORT_REVERSE_NAME` to the `scripting.cpp` call for
loading tables. I didn't like this one because this bug can in theory
impact non scripting tables.

Here's a log from Solaris working with the new build:
https://fsnebula.org/log/5d7b4f37cb0d332b3d6b5ed3#True-138

While it might be a reasonable enhancement in the future to build a proper dependency system for lua scripts and tables,
this is a much smaller and easier change, and doesn't require any work from modders.
2019-09-13 17:22:15 +02:00
Goober5000 e1a0a8a2fb Merge pull request #2093 from tcrayford/update_object_facing_help_strings
update set-object-facing and set-object-facing-object sexp help
2019-09-07 15:20:49 -04:00
Tom Crayford 1cd22ba827 update set-object-facing and set-object-facing-object sexp help
As per the discussion in https://github.com/scp-fs2open/fs2open.github.com/issues/2092,
if you specify the turn time, these can behave quite weirdly.
Some mods that we don't want to break backwards compatability with use
that mode, but at least we can note the pitfalls in help.
2019-09-07 18:36:35 +02:00
m!m 4f884b5035 Merge pull request #2091 from asarium/fix/crashInJoystick
Fix crash in joystick code
2019-09-03 22:07:16 +02:00
asarium 894228cc7c Fix crash in joystick code
Not sure why we didn't catch this earlier but this should hopefully fix
the crash. The cause was that we constructed an SCP_string from a null
pointer instead of using the empty string as the default.
2019-09-03 19:53:04 +02:00
Goober5000 8f8afbc189 Merge pull request #2087 from asarium/feature/crashdumps
Write Minidumps when a crash occurs
2019-08-29 14:18:58 -04:00
Cliff Gordon f4bfec5029 Merge pull request #2089 from asarium/build/fixTravisGitHubToken
Update Travis GitHub token
2019-08-28 12:45:13 -05:00
asarium c18f775962 Update Travis GitHub token
The token used by Travis was also out of date so here is a new one. This
is a token created by the SirKnightly user.
2019-08-28 18:14:49 +02:00
Goober5000 608dcb6b44 Merge pull request #2088 from asarium/build/fixAppveyorGitHubToken
Update GitHub token used for AppVeyor release building
2019-08-26 15:10:35 -04:00
asarium b4b23e266b Update GitHub token used for AppVeyor release building
For some reason the old token was removed from the AppVeyor GitHub
account which made the release build fail.
2019-08-26 17:58:12 +02:00
asarium c41eef517b Write Minidumps when a crash occurs
This will write Mini dumps in the event that the executable causes a
crash. This will allow us to take a closer look at any crashes without
having to reproduce them.
2019-08-25 20:22:23 +02:00
m!m 65e2aa88b3 Merge pull request #2059 from asarium/build/travisWindowsAlways
Do not allow failure for Windows Travis builds anymore
2019-08-24 13:11:29 +02:00
asarium fe0c6a629a Do not allow failure for Windows Travis builds anymore 2019-08-22 17:36:28 +02:00
MageKing17 730c62af81 Merge pull request #2085 from Goober5000/issue_2081_actual_fix
Issue 2081 actual fix
2019-08-19 23:52:40 -07:00
Goober5000 13d4ebaceb leave a 'node' variable pointing to the beginning of the sexp node list so that we can manipulate it later 2019-08-19 23:35:55 -04:00
Goober5000 ed6a780898 Revert "fix for issue #2081" 2019-08-19 23:19:30 -04:00
Goober5000 f0b9929cd3 Merge pull request #2083 from Goober5000/eval_nums_redo
fix for issue #2081
2019-08-19 18:13:45 -04:00
Goober5000 f315caad95 fix a bug, and use Error instead of Warning since this indicates a programming error 2019-08-19 16:29:49 -04:00
Goober5000 b5a47e651f fix for issue #2081
This re-implements the eval_nums function to use C varargs, instead of C++11 template parameter packs.  This is necessary because Visual Studio has a bug where template parameter packs corrupt heap memory somehow.
2019-08-19 16:19:53 -04:00
m!m d49299225c Merge pull request #2080 from tcrayford/de_fault_is_in_de_spelling
fix typo: defualt->default
2019-08-11 14:33:32 +02:00
Tom Crayford 3b0bb79d79 fix typo: defualt->default 2019-08-11 11:09:13 +01:00
Goober5000 daacdc0035 Merge pull request #2078 from FSCyborg/Fix-#1433-
Fix 1433 Take two
2019-08-10 22:41:03 -04:00
FSCyborg 39df9ef90e Fix 1433 Take two
Have FSO check for subspace and start the loop up again when subspace is being used.
2019-08-09 22:21:33 -04:00
Goober5000 fc080cccbd Merge pull request #2075 from FSCyborg/fix#1916
"Fix" 1916
2019-07-30 22:59:47 -04:00
FSCyborg 0c07ad9d71 "Fix" 1916
Adds a check to see if the subsystem is the same before restting aspect lock.

More of an enhancement to expected behavior than a bugfix.
2019-07-30 17:58:52 -04:00
Goober5000 7d329bbbc6 Merge pull request #2074 from FSCyborg/fix#1974
Fix#1974
2019-07-30 12:33:40 -04:00
m!m 17a449529f Merge pull request #2060 from Mithi83/bug/1987-lab-thrusters
fix bug #1987: thruster rendering in lab
2019-07-30 11:59:36 +02:00
FSCyborg 73f0addc42 Fix#1974
"Cloning" failure was actually being caused by the pilot verification function resetting all pilot info and then not loading controls from the file to replace them.

The Control_Config array would all be set to -1 and then would get written into the file the next time the player was saved, making it seem that the controls were not being copied.

The original and current code would reset controls to defaults when a pilot was created.  And it would just let the old controls remain in case of a clone. The above problem would occur just as you hit accept on the bottom of the baracks screen.
2019-07-29 21:25:50 -04:00
Goober5000 0ba1583d90 Merge pull request #2035 from Goober5000/patch_nan_handling
when evaluating numeric SEXPs, handle NaN properly
2019-07-28 01:03:11 -04:00
Goober5000 2436697f2c Merge pull request #2071 from FSCyborg/Fix#2067
Fix#2067
2019-07-27 22:51:24 -04:00
FSCyborg 0e10100aad Fix#2067
Original behavior in Fred was accidentally removed when upgrading the FSO mission parser to keep it from crashing FSO from a bad sexp.  But returning false is only necessary in FSO since in FRED, we can fix the error once we know about it.
2019-07-27 21:21:33 -04:00
Goober5000 60bcdefac0 remove unneeded header 2019-07-25 15:14:45 -04:00
Goober5000 5d8ac3cc11 bring up to date with another eval_num 2019-07-25 15:14:45 -04:00
Goober5000 e0bc2f188b help the compiler out a bit, per Gasbow's suggestion 2019-07-25 15:14:45 -04:00
Goober5000 d13bbdd534 move eval-num derivatives out of the header file 2019-07-25 15:14:45 -04:00
Goober5000 44b09d137f let's try a function pointer instead of std::function 2019-07-25 15:14:45 -04:00
Goober5000 4439edcb4d more complaints 2019-07-25 15:14:45 -04:00
Goober5000 a9ddeda40e edits and clang-tidy 2019-07-25 15:14:45 -04:00
Goober5000 d606e4d952 complaints and stuff 2019-07-25 15:14:44 -04:00
Goober5000 2fa8a0bd84 that const crept back in again 2019-07-25 15:14:44 -04:00
Goober5000 f9d178d46b additional small fixes 2019-07-25 15:14:44 -04:00
Goober5000 989235936e when evaluating numeric SEXPs, handle NaN properly
NaN should propagate through the SEXP tree, but not all SEXPs do this properly.  The problem was made worse after I introducted `eval_num()` which silently ignored NaN values.  This commit adds new boolean arguments to `eval_num()` to flag NaN results, and changes all calls of `eval_num()` to properly handle the new arguments.  Additionally, this adds `eval_nums()` and `eval_array()` functions to more smoothly handle cases where many numbers appear in a row.
2019-07-25 15:14:44 -04:00
Goober5000 6df9c73a4c Merge pull request #2063 from Goober5000/modify_set_object_position
Allow positioning sexps to work on ships yet to arrive
2019-07-25 14:13:38 -04:00
Goober5000 d794eb6e77 Merge pull request #2070 from FSCyborg/Coverity#1093387
Coverity 1093387
2019-07-20 20:31:01 -04:00
Goober5000 e5c06c9554 Merge pull request #2069 from FSCyborg/Cyborg-Coverity-Fixes
Coverity 1093370
2019-07-20 18:14:38 -04:00
FSCyborg bc00b79922 Coverity 1093387
We already verify that the variable will not be null in the previous code block.
2019-07-20 16:12:45 -04:00
Goober5000 e1e86667b3 Merge pull request #2068 from FSCyborg/Fix#1791
Fix#1791 ChangeIFF & Laser_Flag
2019-07-20 01:05:33 -04:00
FSCyborg 881f787ac8 Fix#1791 ChangeIFF & Laser_Flag
Extremely rare bug caused by use of multiple protect from weapon flags. One of the Ai-Turret functions was setting only one of the flags because "else if" was typed instead of "if".
2019-07-19 21:21:58 -04:00
FSCyborg 88d5bed064 Coverity 1093370
Copy paste error, I can think of no reason to compare Max y and Min z
2019-07-19 09:11:14 -04:00
m!m d9b1659efc Merge pull request #2064 from asarium/fix/scriptingDeprecation
Move deprecation of createParticle to the next version
2019-07-15 19:46:50 +02:00
Goober5000 f6408113f2 fix stuffing of vector pointer 2019-07-15 13:15:21 -04:00
asarium 6075c17255 Move deprecation of createParticle to the next version
This should fix a problem with the MVPs.
2019-07-15 17:54:41 +02:00
Goober5000 da9f71dac0 might as well do set-object-facing and set-object-facing-object as well 2019-07-14 23:26:18 -04:00
Goober5000 03f1344794 might as well do set-object-orientation too 2019-07-14 21:24:22 -04:00
Goober5000 59e9d7cb0c add missing break to case 2019-07-14 21:20:33 -04:00
Goober5000 910595880a Allow set-object-position to work on ships yet to arrive
This adds `set-object-position` functionality for ships and wingmen still on the arrival list.  Requested by JSRNerdo.
2019-07-13 14:24:06 -04:00
MageKing17 9f07e43455 Merge pull request #2020 from asarium/feature/scriptingDeprecation
Add deprecation feature for the scripting API
2019-07-11 15:08:45 -07:00
m!m 7b8c156980 Merge pull request #2022 from asarium/opengl/smaa
Add SMAA post processing step
2019-07-11 18:02:47 +02:00
Thomas Jansen f8c11ccd2e fix bug #1987: thruster rendering in lab
Lab_selected_index must remain unchanged until labviewer_change_model is
called. There the variable is used to determine if a new ship must be
created and updated afterwards.
2019-07-07 08:36:55 +02:00
Goober5000 7e36dc8afe Merge pull request #2058 from FSCyborg/master
Coverity 1093382
2019-07-05 12:25:53 -04:00
FSCyborg b1ad89a9fa Update chttpget.cpp 2019-07-04 10:14:07 -04:00
FSCyborg 4d9b1a7674 Update chttpget.cpp 2019-07-03 15:03:34 -04:00
FSCyborg 72f3871b7b Update chttpget.cpp 2019-07-03 10:14:24 -04:00
FSCyborg 7906ff460a Coverity 1093382
Coverity spotted this dead code.  Looks like the original coder forgot that they had checked for !p already or was a case of mindless copy-pasting code..

Because of
pcode = strchr(p,' ')+1;
it looks like it really is safe to remove.
2019-07-02 23:18:13 -04:00
asarium 1eb1923751 Add SMAA 2019-06-30 13:28:05 +02:00
asarium 6d1931bf99 Add function for drawing full screen using oversized triangles
This replaces the current instances where two triangles are used for
drawing a full screen quad.
2019-06-30 13:08:45 +02:00
asarium f75cb1edd3 Add deprecation feature for the scripting API
This allows to mark certain functions or virtvars to be declared as
"deprecated" starting with a specific engine version. What this means is
that a special message will be added to the documentation stating since
when the function is deprecated and can contain an optional message. The
actual enforcement of the deprecation depends on the target version of
the mod so that we can stay backwards compatible.

If the mod supports the version since when the function is deprecated,
it will not be added to the Lua state which means that it doesn't exist
for the calling script. If the targetted version is before the stated
version, the function will still be added to the Lua state.

As the first function to use this feature, I have deprecated
createParticle in the testing library and moved it to the graphics
library with a new name reflecting that it creates a persistent
particle. I also added the corresponding function for adding a
non-persistent particle.
2019-06-30 11:31:32 +02:00
Goober5000 48586bc857 Merge pull request #2055 from wookieejedi/fix_weapon_icon_override
Bug fix: adds missing conditional when using weapon icons and 3D weapon selection
2019-06-28 18:29:07 -04:00
Goober5000 3adb861640 Merge pull request #2057 from wookieejedi/fix_blownoff_bug
Fix blown_off bug for good
2019-06-28 18:17:34 -04:00
wookieejedi 7b1f407c22 Fix blown_off bug for good
Thanks for @SamuelCho for telling me what to put to fix this bug for good. This PR fixes #2046 (for good it seems!).
2019-06-28 15:33:29 -04:00
Goober5000 ed5b4b9b5a Merge pull request #2054 from Goober5000/itld_bugfix
properly indicate that player ships have departed at the end of a mission
2019-06-27 15:21:09 -04:00
niffiwan b63ddf08bb Merge pull request #2056 from SamuelCho/subsys_destroyed_fix
Make sure various model rendering/collision code reference submodel instances instead of the prototype data
2019-06-27 20:39:19 +10:00
SamuelCho 816d8e5415 Make sure various model rendering/collision code reference submodel instances instead of the prototype data. 2019-06-25 22:33:52 -07:00
Goober5000 e7e43e9466 Merge pull request #2044 from niffiwan/fix/capitalplus_vs_shields
Fix AI selection of capital+ weps vs shields
2019-06-25 22:19:49 -04:00
wookieejedi 48e630dfd1 Add () to fix travis error 2019-06-25 17:17:02 -04:00
wookieejedi 00f2ddc8da Bug fix: adds missing conditional when using custom icons and 3D weapon selection
Previously if the 3D_weapon flag was used it would always create a weapon icon and overrride any pre-existing icons the modder would specify. This PR fixes that by adding an extra set of conditionals, which specify if a weapon has an icon file name then it should be used, and if the weapon does not have an `$Anim:` but does have a model then that model should be used if the 3D_weapon flag is enabled.
2019-06-25 16:20:13 -04:00
Goober5000 c6d93275c2 address clang complaint 2019-06-24 13:03:38 -04:00
Goober5000 e2ce0bea9b tweak comment 2019-06-24 02:13:19 -04:00
Goober5000 a98fd2cb54 use the new 'mission_check_ship_yet_to_arrive' function when appropriate 2019-06-24 02:11:35 -04:00
Goober5000 5444e81fab add new function for properly evaluating ship arrivals 2019-06-24 01:28:07 -04:00
Goober5000 83276a355d if ship is departing to jump node, add that to the script hook 2019-06-23 16:05:36 -04:00
m!m 98606b37e4 Merge pull request #2053 from wookieejedi/arc_color-options
Adds Table Option to Modify Arc Colors
2019-06-23 09:17:00 +02:00
wookieejedi c4a7e9694f Fix error message vars 2019-06-22 20:50:29 -04:00
wookieejedi 2db1758ec2 Use stuff_int_list
Incorporate m!m feedback
2019-06-22 17:59:59 -04:00
wookieejedi cff070dc07 Update to using tuples and error checks
Incorporates m!m's feedback.
2019-06-22 16:07:55 -04:00
wookieejedi 7b3ad77f36 Adds Table Option to Modify Arc Colors
This PR adds a table entry that allows modders to specify the RGBI values for the damage and emp arc colors (which were previosuly hardcoded).

This option adds the table entry to `Game_settings.tbl` under `#Graphic Settings` with the lines:
```
$EMP Arc Color:
	+Primary Color Option 1: rgb
	+Primary Color Option 2: rgb
	+Secondary Color Option 1: rgb

$Damage Arc Color:
	+Primary Color Option 1: rgb
	+Primary Color Option 2: rgb
	+Secondary Color Option 1: rgb
```
2019-06-21 14:58:05 -04:00
Goober5000 d67e79a44b Merge pull request #2042 from Goober5000/nested_subsys_destruction
properly handle destruction/repair of subsystem tree
2019-06-06 01:48:03 -04:00
niffiwan 977190b358 Address review feedback
Make wip an actual pointer!
Rename some vars to better reflect their usage (vs previous copy-pasta)
2019-06-04 18:39:21 +10:00
m!m ba3237604e Merge pull request #2048 from wookieejedi/per_shipclass_help_threshold
Add per ship class options for when AI sends "Help Me" message
2019-05-29 18:44:46 +02:00
Goober5000 a94550ee1a Merge pull request #2049 from plieblang/MapIteratorCleanup
Clean up map::iterator usage
2019-05-25 00:45:46 -04:00
wookieejedi d55a6632ca and one more float to specify 2019-05-24 23:58:52 -04:00
wookieejedi 680cb580cd specify rest of floats 2019-05-24 23:49:19 -04:00
wookieejedi 2f74940f6a specify float 2019-05-24 23:00:55 -04:00
plieblang 3dbe27e772 Clean up map::iterator usage 2019-05-24 13:43:04 -07:00
wookieejedi 72d876bd4b Switch to const and add error checks
Incorporatea ll of m!m's feedback.
2019-05-23 15:35:59 -04:00
wookieejedi e22398bec8 Add per ship class options for when AI sends "Help Me" message
This PR allows modders to set, on a per-ship class basis, the fields for what hull and shiled integrity the AI wingmen send the "Help" message at. One good use case is when ships have low hitpoints, thus now the modder can set AI can call for help sooner then at simply 30% hull.
2019-05-23 13:19:30 -04:00
Goober5000 11661db6ab oops -- get distance before setting it to 9999999 2019-05-17 14:31:16 -04:00
Goober5000 6164004df3 repair parent submodel if it needs repairing 2019-05-17 14:31:16 -04:00
Goober5000 505aa3cdd1 organize subsystem modification sexps to all call one function 2019-05-17 14:31:16 -04:00
Goober5000 cfeb8da3d3 don't reuse subsystems that are skipped 2019-05-17 14:31:15 -04:00
Goober5000 ec7945276a handle child subobjects being destroyed 2019-05-17 14:31:15 -04:00
Goober5000 2bf19afb94 make sure all instances of ship_recalc_subsys_strength happen after do_subobj_destroyed_stuff 2019-05-17 14:31:15 -04:00
Goober5000 34b38f63fa remove unneeded function 2019-05-17 14:31:15 -04:00
m!m 8f11d2e11c Merge pull request #2037 from Goober5000/on_subsystem_destroyed
add $On Subsystem Destroyed scripting hook
2019-05-17 19:47:11 +02:00
Goober5000 e4036b9e5a Merge pull request #2045 from MageKing17/bugfix/multi-sexp-flag-validity
Check flags are valid in multi_sexp_deal_with_ship_flag().
2019-05-17 13:42:09 -04:00
MageKing17 c86e94a4e7 Correct NULL to nullptr so clang-tidy is happy. 2019-05-17 09:13:02 -07:00
MageKing17 a6475f59f0 Check flags are valid in multi_sexp_deal_with_ship_flag().
In single-player, or while running as a server, sexp_deal_with_ship_flag() makes sure that object_flag, ship_flag, and p_object_flag aren't NUM_VALUES (i.e. not set) before trying to call flags.set() with them. However, the client code in multi_sexp_deal_with_ship_flag() had no such security checks, and as such would try to set NUM_VALUES, which is outside the range of valid flags; this led to a crash in Release builds and an Assertion otherwise.
2019-05-13 12:29:54 -07:00
Goober5000 69ebdd0417 Merge pull request #2043 from wookieejedi/add_gethotkey_sexp
Adds `get-hotkey` sexp
2019-05-13 13:32:21 -04:00
niffiwan 9444b9ff9f Merge pull request #2024 from CasparKielwein/collision_cleanup_ck
Refactoring of objcollision
2019-05-13 19:41:38 +10:00
niffiwan 4c7470fbf2 Fix AI selection of capital+ weps vs shields
Current the AI always selects capital+ weapons vs big/huge ships. This
makes the AI take shields into accounts, and not use the weapon if
either the shields are still up, or the weapon isn't good vs shields.

I don't greatly like the magic number 1.33 to determine if a weapon is
good vs shields, I'm happy to take alternative suggestions. I have
checked DE, WoD & BP tables and I don't think this change will affect
any of them (picked them because their either use capital+ weapons or
have shielded capships)

There's one DE weapon that the AI won't select anymore while shields
are up; however its fluff says it's bad vs shields and suggests a
paired shield-breaker so think it should be OK.
2019-05-12 15:50:13 +10:00
wookieejedi 8d3eeec238 Updated description 2019-05-11 14:03:15 -04:00
Goober5000 da0ff33fcb address feedback and implement asarium's suggestion 2019-05-11 13:06:21 -04:00
wookieejedi 764b4b8422 Improve comments and description 2019-05-11 10:38:40 -04:00
m!m a5d22589ec Merge pull request #2036 from wookieejedi/class_flyby_sounds
Adds per-class flyby sounds
2019-05-11 12:28:09 +02:00
wookieejedi 6a6940e0f0 Adds get-hotkey sexp
This PR adds a sexp that returns the integer value of a ship or wing hotkey. No hotkey returns -1, F5 returns 0, F6 returns 1, ... and the sexp takes one arguemnt, the ship or wing name.
2019-05-10 23:09:00 -04:00
niffiwan 2dfd9936d8 Merge pull request #2041 from niffiwan/fix/issue2040
Don't link if ship has 'no primary linking' flag
2019-05-11 10:19:29 +10:00
Goober5000 fb0847f4b5 Merge pull request #2038 from wookieejedi/add_sethotkey_sexp
Add new sexp: `add-remove-hotkey`
2019-05-10 17:50:48 -04:00
wookieejedi 7b959b09d2 Incorporate Goober's feedback 2019-05-10 15:34:05 -04:00
wookieejedi f4b713c56c Add bool arg 2019-05-10 15:12:49 -04:00
wookieejedi d32d3f55d1 Updated name and function
Incorporated all revisions and suggestions
2019-05-10 09:32:15 -04:00
niffiwan 1ebb72ee88 Don't link if ship has 'no primary linking' flag
Also adds/enhances some handy nprintf debug statements.
Fixes #2040
2019-05-10 23:06:16 +10:00
wookieejedi a988d0e972 Adds a new sexp, set-hotkey
This new sexp allows a FREDer to set a hotkey for a ship or wing. The sexp takes 2 or more arguemnts, the integer of the hotkey to set (F5=0, F6=1, ... F12=7) and the names of the ship(s) and/or wing(s).
2019-05-09 13:46:21 -04:00
Goober5000 8aa2f3b099 tweak spacing 2019-05-08 20:04:19 -04:00
Goober5000 8365f0abb7 add $On Subsystem Destroyed scripting hook
Implements the feature request from issue #610.

As an aside, this PR also patches the `ship_set_subsystem_strength` function (which is only used by the debug console and in the event you fire at your training instructor) to use the same code as the `set-subystem-strength` sexp.  This properly handles submodels blown off, sounds, etc.
2019-05-08 19:55:03 -04:00
wookieejedi 4afe739cbb Clean and shorten per request
Fixes spelling error in comment, uses proper flyby_snd and makes code more concise.
2019-05-08 14:14:01 -04:00
wookieejedi 2c469e0c88 Adds per-class flyby sounds
Previosuly, flyby sounds were only specified on a per-species basis. This PR allows each ship class to use a specific flyby sound. This will allow modders to set the custom sound in ships.tbl, just like any other per-class sound.
2019-05-08 14:00:28 -04:00
MageKing17 822e61665d Merge pull request #2026 from Goober5000/some_sexp_fixes
various sexp formatting and cleanup changes
2019-05-07 07:18:28 -07:00
niffiwan 5f5616c0fa Merge pull request #2030 from niffiwan/feature/deathroll_customisation
Allow death max rotation to be set per ship
2019-05-07 19:28:54 +10:00
Goober5000 b38f6aa014 HA! 2019-05-06 14:07:11 -04:00
Goober5000 d88e6f5a88 Merge pull request #2034 from niffiwan/fix/issue2033
Null wp_list on setting order, same as for sexps
2019-05-06 14:01:58 -04:00
niffiwan 760b601a95 Null wp_list on setting order, same as for sexps
Making wp_list null lets ai_mission_goal_achievable reset the waypoints
list correctly, otherwise it thinks the waypoints are ok when in fact
something has invalidated them
2019-05-06 18:30:38 +10:00
Fabian Woltermann 0bf116b0cc Merge pull request #2032 from The-E/fix/2031_copy_paste_error_in_lua_vecmath
Fix for error in validation of matrices accessed by lua
2019-05-06 07:51:40 +02:00
The_E 2180296f9c When setting individual elements of a matrix through lua, we need to mark the matrix as either having out of date angles or out of date vectors. 2019-05-05 20:06:28 +02:00
niffiwan b84fe72778 address feedback
This moves DEATHROLL_ROTVEL_CAP to shiphit.h & converts it to a
constexpr float
2019-05-05 22:13:32 +10:00
niffiwan c5e460a90d Allow death max rotation to be set per ship
This allows modders to restrict the amount of rotation in a death roll.
It's fairly simple to fit in with the existing code which has a lot of
hard coded constants. The intended use case is to restrict pitch &
heading changes so there's less chance of rapid forward rolls or flat
spins, especially with faster-than-FS2 ships.

I'd almost rather rewrite the entire code to dynamically use ships mass
& velocity except for retail compatibility issues.
2019-05-05 10:07:21 +10:00
CasparKielwein 271d3f97bd remove unused functions obj_add_pair and obj_add_pairs in object code.
These functions where not used anymore and probably made redundant
by swifties changes to the collision system in 2012.
2019-05-04 11:30:54 +02:00
CasparKielwein e70d6a89ee objcollide cleanup: declare local variables at point of first use
made some loops range based.
removed some typedef struct, as it is c++.
2019-05-04 11:30:16 +02:00
Goober5000 d1a8e66fce Merge pull request #2029 from niffiwan/fix/qtfred_mission_load_failure
Allow qtFred to open missions again
2019-05-04 01:58:58 -04:00
niffiwan 964f8f5ef1 Allow qtFred to open missions again
Minor miss from 9332311b57
Also has trivial comment fix
2019-05-04 14:02:50 +10:00
Goober5000 8ebe012e12 more complaints 2019-05-03 15:24:16 -04:00
Goober5000 92f142452a even more complaints 2019-05-03 14:07:13 -04:00
Goober5000 cfb80cfd16 fix modulo 2019-05-03 13:59:48 -04:00
Goober5000 39313ed8d7 Address feedback. Also fix a few things github complained about. Also fix depart-node-delay by correctly handling the 'delay' parameter as a value of type 'fix', just like the other *-delay sexps. 2019-05-03 13:06:51 -04:00
MageKing17 1da2c03cef Merge pull request #2016 from Goober5000/a_few_good_sexps
Three sexps and some sexp improvements
2019-05-01 20:13:11 -07:00
Goober5000 f9dbe4941b various sexp formatting and cleanup changes 2019-05-01 22:45:59 -04:00
Goober5000 46319f1b4e Merge pull request #2025 from Mithi83/bug/1827-targeting-brackets
fix bug #1827: targeting brackets stuck in top left corner
2019-05-01 14:31:47 -04:00
Thomas Jansen 8653d824cd fix bug #1827: targeting brackets stuck in top left corner
Every g3_start_frame must have a matching g3_end_frame. Thus, a return
in the middle of a function after an opening g3_start_frame must make
sure to call g3_end_frame before it leaves to avoid a dangling frame
context.

As described in the bug report at
https://github.com/scp-fs2open/fs2open.github.com/issues/1827
a floating point rounding issue could be the trigger for the problem.
2019-05-01 18:32:26 +02:00
CasparKielwein 3e7e7cde00 made functions from objcollide, which are only used in .cpp local to compilation unit 2019-05-01 10:41:27 +02:00
CasparKielwein f63667b29e Cleanup in objcollide: Remove code that was commented out 2019-05-01 10:07:35 +02:00
CasparKielwein b42fc2122a Cleanup in object collide code.
A bit of small cleanups in preparation of larger scale refactoring.

remove unused member heavy_collision_cm_pos of collision info struct,
which was set in several places but never used.
2019-05-01 09:44:19 +02:00
Goober5000 3ca4ba16fe Merge pull request #1892 from asarium/feature/optionsUI
Add new options system
2019-04-29 17:16:21 -04:00
Goober5000 36c14e21e8 Merge pull request #2021 from asarium/feature/axemWantsLuaAudioAPIs
Add unload function for freeing audio memory of a soundfile handle
2019-04-29 17:07:48 -04:00
asarium ce1ea75714 Add unload function for freeing audio memory of a soundfile handle
This can be used by scripts for explicitly freeing up some memory when
necessary.
2019-04-27 08:53:07 +02:00
Goober5000 30373e9138 Merge pull request #2019 from wookieejedi/clean_fix_showship_detailbox_bug
Cleaner fix for show-ship bug with detail_box calculations
2019-04-22 19:15:56 -04:00
wookieejedi 9e460332a6 add ship check
per Goober's request added a ship check
2019-04-22 17:53:07 -04:00
wookieejedi 473e2588bf Cleaner fix for show-ship bug with detail_box calculations
This provides a cleaner fix for the bug where using show ship caused detail_box calculations to incorrectly work on the player's ship.

It also reverts the changes made by PR #2018.
2019-04-22 10:28:41 -04:00
niffiwan 6350110b21 Merge pull request #2018 from wookieejedi/fix_detailbox_with_showship
Fix `detail_box` calculations when using `show ship`
2019-04-21 18:49:16 +10:00
wookieejedi 0c92134de5 fix detailbox using show ship
This PR fixes issue #2015, which is a bug where using `show ship` caused detail_box calculations to incorrectly use world coordinates for submodels on the player's ship, rather then the correct local coordinates.
2019-04-20 20:45:14 -04:00
Goober5000 681dd9b871 Merge pull request #1993 from niffiwan/fix/blackdetailboxes
detail boxes can ignore default distance scaling
2019-04-19 13:43:51 -04:00
Goober5000 213422076e KNOWN_ values aren't returned after all, derp 2019-04-19 00:34:39 -04:00
Goober5000 41aff9d094 ooooooops 2019-04-19 00:14:53 -04:00
Goober5000 337ca94b53 write out the full word 'number' 2019-04-18 01:18:05 -04:00
Goober5000 13f5037b0c add is-nan, nan-t-num, and functional-if-then-else 2019-04-18 01:12:00 -04:00
Goober5000 221d96f5d6 defensively check both regular and known sexp boolean values 2019-04-18 01:11:19 -04:00
Goober5000 bd6441004b optimize eval_sexp by not reconciling positive/negative if we have a magic number 2019-04-18 01:09:36 -04:00
Goober5000 14b6e86e5d made the SEXP_ numbers even more unlikely, in case someone wants to use large negative numbers 2019-04-17 12:32:51 -04:00
m!m 4824428971 Merge pull request #2014 from MageKing17/feature/ssm-strike-warp-effect-field
Add "+WarpEffect:" field to ssm.tbl.
2019-04-14 13:01:52 +02:00
MageKing17 6af8d4ccbd Add "+WarpEffect:" field to ssm.tbl.
Allows subspace strikes to choose which fireball to use for the warp effect. If absent, FIREBALL_WARP is used as the default (which was the previous hardcoded behavior).

"+WarpEffect:" can be specified as either an index or using the fireball's unique ID.
2019-04-13 20:35:52 -07:00
niffiwan d2d730138f Merge pull request #2013 from chief1983/fix/revert_nightly_test
Revert "Test the upload"
2019-04-08 02:38:22 +10:00
Cliff 7d67d16094 Revert "Test the upload"
This reverts commit 5fa5a199bf.
2019-04-07 09:15:41 -05:00
niffiwan 3f4eb05f3e Merge pull request #2012 from chief1983/fix/travis_uploads
Make sure to use a path that contains the new curl binary
2019-04-07 08:54:36 +10:00
Cliff Gordon 49f8660f7a fix/travis_uploads: Make sure to use a path that contains the new curl binary. 2019-04-06 13:20:35 -05:00
niffiwan 2833ae150f detail boxes can ignore default distance scaling
Add a submodel property that overrides the hard-coded distance
multipliers applied to the distances at which details boxes & spheres
are rendered. The distance multipliers are set by the "model detail"
setting in the options screen. Note that this is different to the LOD
distance multipliers which are not hard-coded.

This allows some more creative uses of detail boxes & spheres, e.g. to
stop models subobjects from being rendered when they're out of player
view. Past testing showed a reasonable performance improvement with
complicated models.

This is a submodel property rather than global, or a ship flag, to allow
flexibility, i.e. a single model could choose this option only for the
submodels that want to use detail boxes/spheres in this fashion, which
other detail boxes/spheres use the conventional approach.

Code & ideas originally from zookeeper, I've just packaged it up for
the PR.

This has been rebased & squashed based on feedback in the PR
2019-04-06 15:24:27 +10:00
niffiwan 8470548376 Merge pull request #2011 from wookieejedi/fix_drawRect_for_scripted_gauge
Fixes minor bug with `drawRectangle` for scripted HUD gauges
2019-04-05 20:20:12 +10:00
wookieejedi ea6bd1d9a4 Update hudgauge.cpp
Fixes a minor bug that incorrectly draws Rectangles to a scripted HUD gauge. The third and fourht arguments needed to be width and heigth, not x2 and y2.
2019-04-04 16:03:45 -04:00
m!m 18c0314652 Merge pull request #2010 from wookieejedi/Add_more_draw_functions_toScriptedGauge
Add more draw functions to scripted gauge
2019-03-30 21:22:28 +01:00
wookieejedi 98165dbce5 Fix typo, drawCirle -> drawCircle 2019-03-30 13:55:12 -04:00
wookieejedi 60bf6dec2c Merge branch 'Add_more_draw_functions_toScriptedGauge' of https://github.com/wookieejedi/fs2open.github.com into Add_more_draw_functions_toScriptedGauge 2019-03-30 09:54:35 -04:00
wookieejedi 252ab4e282 Follw m!m request for optional arg 2019-03-30 09:54:01 -04:00
wookieejedi bd93c8e661 Merge pull request #2 from wookieejedi/master
Rebase
2019-03-30 09:50:35 -04:00
wookieejedi 0e4056f795 Merge pull request #1 from scp-fs2open/master
Rebase
2019-03-30 09:49:10 -04:00
wookieejedi 8f877d3826 Fixed typo 2019-03-29 09:36:10 -04:00
wookieejedi 6025ab8318 Update drawCircle too to match gr.drawCircle 2019-03-29 08:57:54 -04:00
wookieejedi 679cbe2526 Made the draw functions more consistent with gr draw functions 2019-03-29 08:53:37 -04:00
m!m fa0140fea7 Merge pull request #2009 from wookieejedi/Add_drawImage_toScriptGauge
Add `drawImage` to Scripted Gauge
2019-03-29 10:57:31 +01:00
wookieejedi 5343503385 Add more draw functions to scripted gauge
This adds the following functions to the scripted gauge API: drawCircle, drawRect, and drawLine. Also note that I created an additional function, for HUDGauge:renderCircle_unfilled, becuase the precedent shown by having two functions for `gr_unfilled_circle` and `gr_circle` and adding a fourth argument to `renderCircle` seemed to affect a lot of other functions.
2019-03-28 16:58:25 -04:00
wookieejedi edd2cb89c7 Removed unneeded include 2019-03-28 13:44:54 -04:00
wookieejedi 6a2327088f Add drawImage to Scripted Gauge
Adds an additional draw function, `drawImage` to the new Scripted Gauge API.
2019-03-28 09:53:19 -04:00
niffiwan f798c5b916 Merge pull request #2007 from asarium/feature/scriptedHudGauges
Add new HUD gauge type for scripted gauges
2019-03-28 21:31:47 +10:00
m!m 76115122a0 Merge pull request #2003 from Goober5000/abort_processing_missions_which_failed_to_parse
cancel mission load when a syntax error is found
2019-03-27 17:58:00 +01:00
MageKing17 b4cb602e31 Merge pull request #2008 from NovachenFS2/new-strings
New translateable strings for the strings.tbl
2019-03-23 09:13:07 -07:00
m!mandNovachenFS2 d26b5310e7 Update code/controlconfig/controlsconfigcommon.cpp
Suggestion

Co-Authored-By: NovachenFS2 <[email protected]>
2019-03-23 14:14:36 +01:00
niffiwan cdb65c154c Merge pull request #2004 from wookieejedi/chase_displays
Add `Chase View Only` Option for HUD Gauges
2019-03-23 10:58:25 +10:00
Jenna Trassa fd0b612c64 New translateable strings for the strings.tbl
This commit adds new id for existing strings, so that they are translateable through the strings.tbl.
The following is translateable now:
- The 'or' seperator in the Keypress Directive gauge, if one function is bound to two keys.
- The Supernova warning.
- The error message that is displayed prior the pilot selection screen, if something is wrong with the loaded modification.
2019-03-22 22:44:35 +01:00
MageKing17 07d83d473c Merge pull request #1999 from asarium/cleanup/cleanupCfileType
Unify Cfile blocks and CFILE handles
2019-03-21 09:02:57 -07:00
asarium 1662a3c317 Add new HUD gauge type for scripted gauges
The new gauge can be accessed by the scripting API with which a function
can be set which will be called when this gauge is rendered. This can be
used for exposing the HUD gauge positioning and RTT options to the
scripting API without a lot of work needed for the script writer.

There is currently only one rendering function implemented since this is
only a proof of concept.
2019-03-17 09:27:58 +01:00
Goober5000 c70e4a0e7e Merge pull request #1991 from niffiwan/fix/issue1867
Fix issues with docked ships warping
2019-03-12 12:53:47 -04:00
niffiwan d82479fb14 tweak variable name for clarity 2019-03-12 21:13:02 +10:00
niffiwan be90059b65 fix documentation & var-name issue
Thanks to Goober5000 for noticing a very confusing var-name & errors in
the comments. Also switch to using bool check without '=='
2019-03-11 19:05:00 +10:00
niffiwan 04abbf55ed address feedback
Switch from 3x specific is_arriving functions to a single with params
Change flag names; replace "ndl" with "dock_follower"
Change dock-arrival helpers to not set follower flag on leaders
2019-03-10 09:26:12 +10:00
niffiwan 1bc925ee9b Merge pull request #2005 from wookieejedi/fix_font_lua_bug
Fixes bug with lua font handle
2019-03-09 10:12:04 +10:00
wookieejedi d558c2d632 Fixes bug with lua font handle
This PR fixes a bug where an invalid lua font handle would not be properly returned as invalid. An invalid handle is returned properly if the font name is invalid, but not if the index is invalid, thus this PR fixes that.
2019-03-08 17:07:21 -05:00
asarium 1c799653ce Unify Cfile blocks and CFILE handles
The only thing a CFILE contained was a version field which isn't used
anymore so that could be removed which basically meant that CFILE was
just an indirection to a Cfile_block which I then just renamed to CFILE.
The CFILE type is an opaque handle now since the contents are not
relevant to a user of Cfile.
2019-03-08 18:34:00 +01:00
wookieejedi 35af3a8b73 Place in correct order 2019-03-07 18:27:00 -05:00
wookieejedi 8586a319b0 Attempt Travis to rebuild 2019-03-07 18:10:30 -05:00
wookieejedi 15748adfda Adding Chase View Only Option for HUD Gauges
Currently, the player is unable to see a RTT hud gauge if in chase view. This adds an option in the hud_gauges.tbl that tells the game whether to draw a gauge based on if chase view is the active view. So for example, a modder using RTT mapped gauges can now make a HUD that displays on the interior of the ship (ie RTT with the cockpit model) and a HUD that displays when the player switches to chase view.
2019-03-07 16:06:51 -05:00
Cliff Gordon 6b0f73e427 Merge pull request #1990 from ngld/fix/curl-mac-upload
Compile curl ourselves on macOS and cache the result
2019-03-06 11:55:46 -06:00
Goober5000 1d744d347c add changes for qtfred 2019-03-06 00:18:40 -05:00
Goober5000 9332311b57 change C-style 0 on success, nonzero on failure to true on success, false on failure 2019-03-05 16:27:06 -05:00
Goober5000 47e9c01ce6 cancel mission load when a syntax error is found 2019-03-05 11:00:57 -05:00
MageKing17 5f176173bd Merge pull request #2000 from asarium/build/luaNatvis
Add natvis file for Lua
2019-03-04 19:48:20 -08:00
MageKing17 8d6538d7a9 Merge pull request #2002 from Goober5000/detroy
spelling fix
2019-03-04 19:39:13 -08:00
Goober5000 cc9e0a1096 spelling fix
now that all troys have been removed from all subsystems, this word can be changed
2019-03-04 17:32:29 -05:00
Goober5000 223e78926f Merge pull request #1998 from Goober5000/fix_missing_weapon_hook_variable
make sure to set all hook variables when the script hook is called
2019-03-04 17:09:31 -05:00
Goober5000 6679b623e4 same script stuff in beam.cpp 2019-03-03 15:20:45 -05:00
Goober5000 8aa2d0e212 a bit of minor housekeeping 2019-03-03 15:02:47 -05:00
Goober5000 1dc449ffa6 standardize order of parameters 2019-03-03 14:39:53 -05:00
Goober5000 6369cdec7c standardize comment 2019-03-03 14:39:25 -05:00
Goober5000 31fe15c4f4 remove hook variables immediately 2019-03-03 14:34:36 -05:00
Goober5000 dd384e7f1d standardize order of parameters 2019-03-03 14:32:54 -05:00
Goober5000 c8fa5803b9 set all hook variables (and unset them immediately after) for debris and asteroids 2019-03-03 14:24:50 -05:00
Goober5000 b57a608177 set all hook variables (and unset them immediately after) for debris and asteroids 2019-03-03 14:20:25 -05:00
Goober5000 f9f7a23b4d clearer invocation of the script hook 2019-03-03 14:11:29 -05:00
asarium 7e88feff16 Add natvis file for Lua
This should make debugging issues with Lua easier by providing a better
view on how the Lua state looks like.
2019-03-03 12:57:40 +01:00
Goober5000 c6bf5e927b make sure to set all hook variables when the script hook is called
In this block of code, the conditions were checked with a set of four hook variables but then subsequently run with only two.  This adds all four previously used variables.  More importantly, it adds the hook variables with expected and user-friendly names, since 'self' and 'object' are not necessarily intuitive.
2019-03-02 21:16:00 -05:00
asarium ad1ede7b74 Add new options system
This is a system for storing arbitrary data in the config file and then
easily retrieving it later on. This has full Lua support for exposing
the available options in a custom UI and changing the values of the
options. This ported some of the existing command line options over to
the new system which is opt-in for the moment by using a mod_table flag.
2019-03-02 14:02:21 +01:00
niffiwan 3c812915e4 add dock-related is_arriving helper functions
Address feedback from PR; reduce the number of hardcoded flags
2019-03-01 19:26:02 +10:00
Goober5000 62963d23ec Merge pull request #1908 from asarium/feature/scriptingFileAutoClose
Add scripting file handle auto-closing and error message
2019-02-27 22:47:18 -05:00
asarium dc71bb47d7 Add scripting file handle auto-closing and error message
This adds some auto-closing code to the scripting API of the CFile
system. If a file has to be auto-closed then an error will be displayed
to let the the script writer know that something is wrong.

This should not break existing scripts since causing file handle leaks
should never happen and if it does, this will make it easier to find
these issues.
2019-02-27 21:16:30 +01:00
m!m b79a3385a1 Merge pull request #1994 from asarium/build/circleci
Add CircleCI config file
2019-02-27 18:05:10 +01:00
asarium dfac2e98e9 Add CircleCI config file 2019-02-26 19:53:11 +01:00
niffiwan 37f2c8249d Fix issues with docked ships warping
There's a number of issues fixed here:
* Radar blips of docked ships were the wrong colour in stage 1
* You could target docked ships in stage 1
* Docked ships thrusters were visible in stage 1
* Hyperspace warptype ship could initially appear at their
warp-destination, then spring back to the correct location to complete
the rest of their warpin (because a docked ship had higher speed than
the dock leader)

There may also be a number of other subtle bugs with docked warpin;
e.g. I suspect (but haven't tested) that AI turrets could fire on
docked ships during warpin
These should also be fixed

Lastly, fixes issue #1867
2019-02-24 09:20:57 +10:00
ngld 5fa5a199bf Test the upload 2019-02-21 19:18:29 +01:00
ngld c00a2897f4 Compile curl ourselves on macOS and cache the result (for Linux as well).
We need to build our own curl binary since Homebrew doesn't support
 --with-libssh2 anymore.
I've also added caching to both the Linux and macOS code to avoid
rebuilding curl for each nightly.
2019-02-21 19:14:41 +01:00
Goober5000 ad4b1ca965 Merge pull request #1988 from niffiwan/fix/isdockedsingle
make is-docked work with a single argument
2019-02-17 11:13:40 -05:00
niffiwan f1f784f237 make is-docked work with a single argument
Currently is-docked always returns true if only a single argument is
supplied. This is probably as designed (except for not erroring on a
single arg) however it's quite easy to update to work for a single
argument and this case is useful for FotG, and might be useful for
others.
2019-02-17 19:19:03 +10:00
Goober5000 2c307ef5d3 Merge pull request #1983 from Goober5000/ship_initialization_tweaks
some tweaks and minor improvements to ship initialization
2019-02-07 14:40:58 -05:00
Goober5000 6f24d8d079 never mind, this is handled in the preloader 2019-02-05 02:23:58 -05:00
Goober5000 9fc94ab873 reconcile script and sexp 2019-02-05 02:21:20 -05:00
Goober5000 728ee2921f move ship_assign_sound into ship_create. also only assign sounds on change_ship_type if Fred is not running 2019-02-05 02:14:05 -05:00
MageKing17 caea0f56ed Merge pull request #1984 from Goober5000/ship_info_flag_fix
fix some flag information
2019-02-04 08:16:10 -08:00
niffiwan 94c9e1b494 Merge pull request #1985 from wookieejedi/AddWaypointHook
Add 'On Waypoints Done' Hook
2019-02-04 19:01:48 +10:00
wookieejedi 7dd1788aee Add 'On Waypoint Done' Hook
Adds 'On Waypoint Done' hook variable for scripting system.
2019-02-03 13:26:35 -05:00
Goober5000 77934c7215 actually it's better to document this 2019-02-02 23:32:57 -05:00
Goober5000 4a7c69082e ¯\_(ツ)_/¯ 2019-02-02 23:27:08 -05:00
Goober5000 74c4075aa6 address clang complaint 2019-01-29 23:43:28 -05:00
Goober5000 008d66c706 fix some flag information
Somewhere along the line, "sentry gun" was replaced with "escape pod" in the inverted is_flyable check.  This made the game think an escape pod wasn't flyable and therefore things like waypoint orders were not displayed.  This PR fixes that.

Additionally, I fixed a potential bug in weapons.cpp where the HUGE flag should really check against HUGE ships.  And there's a no-op formatting change in hudtargetbox.cpp.
2019-01-29 23:35:37 -05:00
Goober5000 1c385901cb prune a bit 2019-01-27 22:27:31 -05:00
Goober5000 5b9b06ab84 some tweaks and minor improvements to ship initialization
The core bug fixed here is #1982.  After ship_create sets up the ship, parse_object_create_sub does further initialization by copying some values from the parse object.  In most cases there are sensible defaults, but a few special cases require some post-processing...

- ship sounds
- the new way of initializing warp effects to allow per-ship customization
- intrinsic-no-shields
- an arrival entry in the mission log
- script hooks

I also took a further look at normal ship creation and tweaked some things...

- initialize ai mode in ai_object_init
- remove redundant assigment of ship name from parse_object_create_sub (it's also done in ship_create)
- remove redundant goal clearing from parse_object_create_sub (it's also done in ai_clear_ship_goals via ship_create)
- avoid overwriting the initial ai mode if the fix-ai-class-bug flag is set
- make the code slightly more efficient by not redundantly setting flags while searching for subsystems
2019-01-27 22:13:14 -05:00
MageKing17 f8da2cdc83 Merge pull request #1979 from MageKing17/bugfix/lua-control-info-player-nullptr-checks
Add checks for Player being nullptr to l_Control_Info.
2019-01-23 06:36:50 -08:00
niffiwan b790d6a388 Merge pull request #1978 from MageKing17/bugfix/lua-useButtonControl-command-definition
Use modulo instead of division in Lua useButtonControl() function.
2019-01-23 19:16:50 +10:00
niffiwan a7ba3fa373 Merge pull request #1977 from MageKing17/bugfix/lua-setButtonControlMode-additive-override-swap
Swap back return values for lua setButtonControlMode() function.
2019-01-23 17:55:25 +10:00
niffiwan 6d7c786a38 Merge pull request #1976 from MageKing17/bugfix/special-messages-skip-lookup
Avoid ship name lookup when sending "special" messages.
2019-01-23 17:54:54 +10:00
MageKing17 49d5356043 Add checks for Player being nullptr to l_Control_Info.
If various functions on l_Control_Info were called while Player was nullptr, FSO would CTD due to a null pointer dereference. This commit adds nullptr checks to avoid the problem.
2019-01-22 20:21:28 -08:00
MageKing17 572565c7bc Swap back return values for lua setButtonControlMode() function.
When setting LUA_ADDITIVE_BUTTON_CONTROL, the setButtonControlMode() function (in l_Base) would return "LUA OVERRIDE BUTTON CONTROL", and when setting LUA_OVERRIDE_BUTTON_CONTROL, "LUA ADDITIVE BUTTON CONTROL" would be returned. This commit simply swaps these back so that the appropriate return value is with the corresponding enum value.
2019-01-22 20:19:14 -08:00
MageKing17 c090ee5405 Use modulo instead of division in Lua useButtonControl() function.
When using a string to define the appropriate control in the useButtonControl() function (in l_Control_Info), the command definition was being divided by 32 when the appropriate mathematical operator was modulo; as a result, the only controls that could actually wind up being referenced are these four: TARGET_NEXT, MAX_THROTTLE, END_MISSION, and MULTI_MESSAGE_HOSTILE. By using the modulo operator, the string lookup now appropriately references the relevant button.
2019-01-22 20:15:46 -08:00
MageKing17 5597b56139 Avoid ship name lookup when sending "special" messages.
MESSAGE_SOURCE_SPECIAL indicates messages whose sender starts with "#", indicating that it's not a ship; however, the code was looking up the source as a ship name regardless, and if the message had a persona set, failing to find that ship name would result in the message failing to send. Commit f67596bc5e (a.k.a. SVN revision 5383) was supposed to fix this, however it was checking if q->source was MESSAGE_SOURCE_SPECIAL when q->source was one of the HUD_SOURCE_* #defines (specifically, MESSAGE_SOURCE_SPECIAL resulted in HUD_SOURCE_TERRAN_CMD). It turned out there was an unused HUD_SOURCE_* #define which behaves identically to HUD_SOURCE_TERRAN_CMD, namely HUD_SOURCE_IMPORTANT. By making MESSAGE_SOURCE_SPECIAL use HUD_SOURCE_IMPORTANT and changing the conditional to compare q->source to HUD_SOURCE_IMPORTANT, the intent behind the original fix can be carried out with minimal effort.

This also fixes issue #1706, which is basically the same as the original mantis issue.
2019-01-22 20:06:22 -08:00
MageKing17 c72a062a84 Merge pull request #1975 from asarium/feature/effectsPerSecond
Add support for "Effects per second" feature
2019-01-21 10:53:23 -08:00
asarium 422753976f Add support for "Effects per second" feature
This allows specifying how many times per second an effect should be
triggered for a particle source instead of triggering the effect every
frame. This will allow modders to achieve more consistent particle
effects regardless of FPS.
2019-01-19 13:56:45 +01:00
Goober5000 374383bacb Merge pull request #1973 from Goober5000/more_lenient_subsys_set_random
replace most Errors in sexp.cpp with Warnings
2019-01-17 23:16:37 -05:00
Goober5000 adfce4ec60 replace most Errors in sexp.cpp with Warnings
This is a follow-up to commit 1614384a6a.  `Error` is to be avoided if possible because almost all sexp problems are recoverable, and we don't want to bring the entire game to a halt.

Also add some more information to warnings about sexp operators on strings.
2019-01-17 12:52:17 -05:00
MageKing17 08faf52871 Merge pull request #1962 from asarium/fix/1961
Update internal NanoVG bitmap data buffer when updating texture
2019-01-14 02:43:08 -08:00
MageKing17 d99121cd52 Merge pull request #1970 from Goober5000/per_ship_warp_type_fixes
fix some bugs with the per_ship_warp_type feature
2019-01-14 01:56:47 -08:00
MageKing17 6ff292a43c Merge pull request #1971 from MageKing17/bugfix/dont-repeatedly-set-selection-effect
Don't repeatedly set selection_effect in parse_ship_values().
2019-01-13 23:26:26 -08:00
Goober5000 09f4f63be4 preserve warp params if we are parsing a TBM 2019-01-14 00:53:51 -05:00
MageKing17 2d67fd3ef8 Don't repeatedly set selection_effect in parse_ship_values().
Every time an entry for a ship was parsed (e.g. every time it showed up in a .tbm), the selection effect would be reset to the default. Since it's already set to the default in the ship_info constructor, this was both redundant and would make it extremely difficult to actually use a selection effect other than the default without constantly setting it in every .tbm.
2019-01-13 21:52:24 -08:00
Goober5000 5666eb5014 tweak comment 2019-01-13 23:51:30 -05:00
Goober5000 8542e9e113 fix some bugs with the per_ship_warp_type feature
Since FRED and FS2 load mission data slightly differently, the warp effect loading code had to be slightly reorganized in order for the warp effects to not be based on invalid data.  Additionally, the warp effects had to be initialized a little bit later so that it could accommodate a new set of warp parameters from the parse object.  As a bonnus, this PR also handles warp effects being reassigned in change_ship_class.
2019-01-13 23:40:59 -05:00
Goober5000 699c9e8d52 Merge pull request #1966 from Goober5000/per_ship_warp_type
per-ship warp type
2019-01-12 13:27:43 -05:00
Goober5000 5b45a89287 restore missing caption 2019-01-12 02:36:32 -05:00
Goober5000 741fc311cd fix comment rot 2019-01-12 02:31:09 -05:00
Goober5000 aaa9c779c0 remove spurious newline; word choice 2019-01-12 01:18:14 -05:00
Goober5000 bfae614189 fix bug: only reverse the warp effect when the ship is warping out; and while we're at it, change that parameter to bool 2019-01-12 01:05:19 -05:00
Fabian Woltermann cb956961f6 Merge pull request #1968 from MageKing17/bugfix/replacement-textures-initialization
Remember to initialize Replacement_textures array after allocation.
2019-01-11 19:24:59 +01:00
MageKing17 6d2ebd1ed7 Remember to initialize Replacement_textures array after allocation.
In commit 9e4c6df219 (PR #1265), the model_render_params::set_replacement_textures() override that accepts a vector of texture replacements was added, which includes allocating its own Replacement_textures array. However, unlike its counterpart from missionparse.cpp, this array doesn't then have all of its elements set to -1. Since it works just fine there, I copied that code here so both versions should behave the same.
2019-01-11 05:21:22 -08:00
Goober5000 d7e6187ba8 Merge pull request #1967 from MageKing17/bugfix/glow-texture-assert-data-check
Avoid using Asserts for data security in modelread properties-reading code.
2019-01-11 00:32:12 -05:00
MageKing17 62f6ee86ef Remove redundant length check, remove asserts from ID_FUEL case.
The (length > base_length) conditional was redundant with the other conditions. Additionally, the code from the ID_FUEL case (thruster points) checking for "$engine_subsystem=" was making the exact same mistake, so I made the same changes there.
2019-01-10 17:58:46 -08:00
Goober5000 56ae91c973 maybe it will work now 2019-01-09 16:08:05 -05:00
Goober5000 dfc8cbd1c9 okay this is pretty stupid 2019-01-09 11:01:32 -05:00
Goober5000 77e61af23c add new files to the project 2019-01-09 09:30:47 -05:00
Goober5000 7b80b0c564 minor header reorganization 2019-01-09 01:44:19 -05:00
Goober5000 a98d3bb064 more clang complaints 2019-01-09 00:59:12 -05:00
Goober5000 741ee07249 address warnings 2019-01-09 00:17:20 -05:00
Goober5000 04cefad927 inherit from ship_info warp params instead of resetting to default 2019-01-09 00:00:53 -05:00
Goober5000 3d68476505 remove WD_ prefix 2019-01-08 23:44:09 -05:00
Goober5000 81c63929b5 stage 3: add FRED2 support 2019-01-08 23:03:37 -05:00
Goober5000 d6d03fbb14 format saves using two-decimal floats, and insert missing newlines 2019-01-08 23:03:37 -05:00
Goober5000 9acd25bc28 create a new convenience function 2019-01-08 23:03:37 -05:00
Goober5000 7e00a8b10f stage 2: allow individual ships to also use Warp_params; implement loading and saving 2019-01-08 23:03:36 -05:00
Goober5000 bb0df2dc43 stage 1: replace individual parameters with an index into Warp_params 2019-01-08 23:03:36 -05:00
Goober5000 38f858198b Merge pull request #1964 from Goober5000/warp_direction_enum
create WarpDirection enum
2019-01-08 22:35:38 -05:00
MageKing17 a83307402a Avoid using Asserts for data security in glow texture reading code.
In a Release build, there was absolutely no code making sure that the text "$glow_texture=" was actually present in the properties field of a glow point bank, beyond a simple strlen() check. Even in Debug builds, there was no guarantee that the text was at the start of the properties field; it was just assumed (without even an assertion verifying it). Now, the assertions have been removed and the appropriate conditions are checked in both Release and Debug.
2019-01-08 15:04:42 -08:00
Goober5000 097148c2c2 remove WD_ prefix 2019-01-07 12:01:17 -05:00
Goober5000 fbf8a931c4 fix warning 2019-01-06 22:38:31 -05:00
Goober5000 32d951b27a create WarpDirection enum 2019-01-06 17:33:47 -05:00
Goober5000 630e6c3e96 Merge pull request #1963 from CasparKielwein/enable_wunusedfunction
enable Warnings for unused functions
2019-01-02 00:12:52 -05:00
CasparKielwein 72ed33502b remove unused and undeclared function hatEnumToIdx in joy-sdl 2018-12-31 16:06:37 +01:00
CasparKielwein d3806b2107 remove unused graphics function is_power_of_two. There is a generic one in ddutils. 2018-12-31 16:05:34 +01:00
CasparKielwein c9a481f4f3 wrapped function only used in debug mode in ifndef NDEBUG in ffmeg 2018-12-31 16:03:15 +01:00
CasparKielwein 0a02f677fe remove unused (and undeclared) function get_subsys_bounding_rect in qtfred 2018-12-31 16:03:15 +01:00
CasparKielwein d55e4343f9 enable Warnings for unused functions in gcc and clang toolchain files. 2018-12-31 14:28:25 +01:00
m!m e902934e89 Merge pull request #1958 from CasparKielwein/dead_code_remove_ck5
remove unused functions O to R
2018-12-31 11:54:18 +01:00
m!m 26395f7c12 Merge pull request #1959 from CasparKielwein/dead_code_remove_ck3
Remove unused Code S to Z
2018-12-30 15:08:15 +01:00
asarium de92fe25e3 Update internal NanoVG bitmap data buffer when updating texture
This was causing issues since the new bitmap data was never stored in
the internal buffer FSO uses for getting the image data. Instead, it was
only uploaded to the GPU texture which could be deleted at any time.
This was the case when changing the "3D Hardware Texture" setting which
causes a texture flush.

This fixes #1961.
2018-12-30 14:00:09 +01:00
CasparKielwein c72fa0917b remove unused functions in render code.
Left those functions in 3dmath alone, as it is more of a library.
2018-12-29 16:45:47 +01:00
CasparKielwein bc0f47269d remove unused functions in radar 2018-12-29 16:45:47 +01:00
CasparKielwein 94469dc43f remove unused functions in playerman 2018-12-29 16:45:47 +01:00
CasparKielwein ce335dbcc2 remove unused functions in physics 2018-12-29 16:45:47 +01:00
CasparKielwein 6660d21f7e remove unused and commented out functions in pcxutils. 2018-12-29 16:45:47 +01:00
CasparKielwein e622d81e89 remove unused functions and defines in object/code 2018-12-29 16:45:47 +01:00
CasparKielwein 10c8e16cda remove unused function in nebula code 2018-12-29 16:45:47 +01:00
CasparKielwein 25029bfdf1 remove unused functions and defines in weapon code 2018-12-29 16:41:23 +01:00
CasparKielwein 2255616ed5 remove unused functions in stats 2018-12-29 16:41:23 +01:00
CasparKielwein 62ab705d75 remove unused and not implemented functions in starfield. 2018-12-29 16:41:23 +01:00
CasparKielwein 77fc335580 remove unused functions in ship/shield and afterburner 2018-12-29 16:41:23 +01:00
CasparKielwein 981b01eea2 remove unused functions in ship/shipfx 2018-12-29 16:41:23 +01:00
CasparKielwein 366dc3749c remove unused functions and variables in ship/ship.cpp and .h 2018-12-29 16:41:23 +01:00
CasparKielwein e693367dd0 remove unused functions in sound 2018-12-29 16:41:23 +01:00
m!m da53960003 Merge pull request #1960 from asarium/fix/cppLuaHandlesPointer
Add Lua state destruction event
2018-12-28 18:46:18 +01:00
Goober5000 687c1ba4f7 Merge pull request #1957 from CasparKielwein/dead_code_remove_ck4
remove unused functions I to O
2018-12-28 11:52:24 -05:00
CasparKielwein d901470880 remove unused functions in model/ code. 2018-12-28 10:29:22 +01:00
CasparKielwein 7e74153a3d remove unused functions in mission code.
There where serval relics of prior refactorings like unimplemented functions.
2018-12-28 10:29:22 +01:00
CasparKielwein 6cf75b77dc remove unused functions in localization code. 2018-12-28 10:29:21 +01:00
CasparKielwein 3ec0a9c35e remove unused functions in lighting code. 2018-12-28 10:29:21 +01:00
CasparKielwein 519f60a63b remove unused globals and functions in mouse support io code 2018-12-28 10:29:21 +01:00
CasparKielwein 252da89782 remove unused function in keyboard support io code 2018-12-28 10:29:21 +01:00
CasparKielwein 0f1b3fd6c2 remove unused function in joystick support code. 2018-12-28 10:29:21 +01:00
CasparKielwein 58722425a3 remove unused function in osapi/dialog.cpp 2018-12-28 10:29:21 +01:00
asarium 211110d415 Add Lua state destruction event
This can be used by the various subsystems for cleaning up Lua
references before the Lua state is destroyed. This avoids having
dangling references to the Lua state which would cause segfaults later
on.

The first subsystem to use this is the dynamic SEXP system which had
dangling references due to keeping Lua references to the SEXP functions.

This fixes #1954.
2018-12-27 14:14:34 +01:00
m!m 61a8aa5592 Merge pull request #1956 from CasparKielwein/unused_function_ck2
remove unused Functions D to H
2018-12-27 13:50:52 +01:00
CasparKielwein 0692286bba Remove dead code in hud directory.
Removed a lot of unused functions.
This is mostly a cleanup of a prior refactoring.
There where a lot of unimplemented functions remaining from renaming.
Removed several outcommented parts of code.
2018-12-26 20:40:20 +01:00
CasparKielwein 72dae916a9 remove dead code in gamessnd/eventmusik
remove unused functions.
remove some uncommented code.
remove unused global variables.
2018-12-26 20:40:20 +01:00
CasparKielwein 189ad9f694 remove two unused functions in gamesequence 2018-12-26 20:40:20 +01:00
CasparKielwein b9f9fa0f73 remove unused function in gameplayhelp: gameplay_help_close 2018-12-26 20:40:20 +01:00
CasparKielwein dc7e88c888 remove unused deinfe in fireball.cpp and unused function fireball_render_plane 2018-12-26 20:40:20 +01:00
CasparKielwein b5dae2a56e remove dead code in debugconsole
remove unused functions.
Remove some unused defines and an unused class in console.h
2018-12-26 20:40:20 +01:00
CasparKielwein 969bfd0bdd remove unused functions in debris 2018-12-26 20:40:20 +01:00
m!m 63e8ae53c5 Merge pull request #1953 from plieblang/SupportDontAddPrimaries
AI profile flag for support to not equip new primary
2018-12-26 14:09:54 +01:00
m!m d57aaac8e4 Merge pull request #1952 from CasparKielwein/dead_code_remove_ck
remove unused functions A to C
2018-12-26 14:02:36 +01:00
plieblang ab981bd415 Document why the flag exists 2018-12-22 14:22:58 -08:00
CasparKielwein df7c91f3e7 remove some unused functions in ai code.
There is a lot of dead code left, but my IDE failds on the 15k file.
2018-12-22 20:10:56 +01:00
CasparKielwein ee73694cc8 remove unused functions on anim
Functionality related to pausing animations was not being used anymore.
2018-12-22 20:10:56 +01:00
CasparKielwein 65dcfe0a7c remove unused functions in autopilot 2018-12-22 20:10:56 +01:00
CasparKielwein ae8f8baade remove unused functions in cutscene 2018-12-22 20:10:56 +01:00
CasparKielwein 86fcdb1502 remove unused functions and variables in controlconfig 2018-12-22 20:10:56 +01:00
CasparKielwein b71fc4595c remove unused functions in cmeasures 2018-12-22 20:10:56 +01:00
CasparKielwein 471402ec5d remove unused functions in cfile 2018-12-22 20:10:56 +01:00
CasparKielwein 97fdca6b52 remove unused functions in camera 2018-12-22 20:10:56 +01:00
CasparKielwein b50833e6fb remove unused or unread variables in bmpman.
Global variables, function pointers and fields,
that where either unused or only set and never read.
2018-12-22 20:10:56 +01:00
CasparKielwein 4429cbb21c remove unused functions in bmpman 2018-12-22 20:10:56 +01:00
plieblang 4a6d8573a0 AI profile flag for support to not equip new primary 2018-12-21 13:26:32 -08:00
m!m 2c6039759c Merge pull request #1951 from Goober5000/fix_comment_rot
fix comment rot in speech.h
2018-12-18 17:42:41 +01:00
Goober5000 f3a0d56a85 remove comment that is no longer applicable 2018-12-18 00:07:40 -05:00
Goober5000 243aac1667 Merge pull request #1934 from plieblang/LabLightingSlidersResetView
Set initial slider values to the command line parameters and add functionality to reset view
2018-12-17 23:58:29 -05:00
Goober5000 19fbe05cee Merge pull request #1949 from Goober5000/small_collision_optimization
simple optimization for obj_sort_and_collide
2018-12-17 16:00:50 -05:00
Goober5000 e581a3b8a3 make these variables global 2018-12-16 14:28:47 -05:00
m!m 67a2d99a9b Merge pull request #1950 from asarium/fix/particleEffectParsing
Improve particle parsing code
2018-12-16 19:12:23 +01:00
asarium 569f1ee237 Improve particle parsing code
This makes some general changes to the particle parsing code. It moves
the trail effect option to the end of the options list to remove an
ambiguity in the resulting parsing code. This is done in a backwards
compatible manner so existing tables will not be broken by this.

This also introduces support for specifying single number ranges
without the parentheses to make that easier to use.
2018-12-16 14:23:22 +01:00
Goober5000 e9a8b9d8a2 make vectors static, per discussion on Discord 2018-12-15 16:45:58 -05:00
m!m 0efb98d4a9 Merge pull request #1948 from MageKing17/bugfix/sexp-nonexistent-AI-class
Don't rely on Assert to check for a valid AI class in SEXP code.
2018-12-13 20:10:34 +01:00
MageKing17 ec99bf9c03 Don't rely on Assert to check for a valid AI class in SEXP code.
Bad data can cause the name search to fail, and if change-ai-class was called with an invalid AI class, it could cause later invalid array accesses (using an index of -1).
2018-12-13 07:00:17 -08:00
plieblang bd6ff021fd Hopefully fix compilation bug 2018-12-09 12:14:43 -06:00
MageKing17 69213c3338 Merge pull request #1947 from asarium/fix/audiofile_play_api_fix
Add missing parameters to soundfile:play
2018-12-08 10:09:03 -08:00
asarium 0bffac7615 Add missing parameters to soundfile:play
This was missing from the API code and was uncovered by the new
scripting API changes.
2018-12-08 17:32:49 +01:00
niffiwan ba089bd95e Merge pull request #1945 from asarium/fix/1944
Fix move constructor of streaminganim_h
2018-12-08 16:17:35 +10:00
m!m 0a1519284f Merge pull request #1943 from TheMatthew/fast-path-microoptimization
Add a cache map for shaders in order to accelerate shader lookup
2018-12-07 18:09:08 +01:00
Matthew Khouzam 877a138192 Update gropenglshader.cpp 2018-12-06 22:53:42 -05:00
m!mandTheMatthew 8a34ceef91 Update code/graphics/opengl/gropenglshader.cpp
Co-Authored-By: TheMatthew <[email protected]>
2018-12-06 22:51:35 -05:00
niffiwan d638cacc51 Merge pull request #1932 from Goober5000/fix_warp_clipping
Fix warp clipping
2018-12-07 07:56:33 +10:00
asarium 871317b5bd Fix move constructor of streaminganim_h
The move constructor was written wrongly which caused issues when moving
the value into the Lua memory. This fixes that issue.

This fixes #1944.
2018-12-06 19:53:50 +01:00
m!mandTheMatthew 9b7a87d4c5 Update code/graphics/opengl/gropenglshader.cpp
Co-Authored-By: TheMatthew <[email protected]>
2018-12-03 20:04:30 -05:00
Matthew Khouzam 3b07636a16 Add a cache map for shaders in order to accelerate shader lookup
Shaders lookup in opengl_get_shader_idx performance reduces from
O(n) shader to O(1).

Signed-off-by: Matthew Khouzam <[email protected]>
2018-12-03 20:03:25 -05:00
m!m 8840d238d7 Merge pull request #1942 from TRBlount/lua/WeaponCreatedHook
Add On Weapon Created Hook
2018-12-03 17:58:03 +01:00
TRBlount 95128dd734 Fix Travis Errors 2018-12-02 01:10:22 -07:00
TRBlount 30866afbd6 Add On Weapon Created Hook 2018-12-02 01:10:22 -07:00
plieblang 2b43677c82 Improve UpdateSlider and add help text 2018-12-01 19:18:36 -06:00
Goober5000 94a542a2a3 Merge pull request #1940 from TheMatthew/minor_cleanup
objectsort: remove useless check
2018-11-29 02:02:44 -05:00
Matthew Khouzam 5c064afd95 Update objectsort.cpp 2018-11-28 23:12:55 -05:00
Matthew Khouzam 6ee41c06d8 Update objectsort.cpp 2018-11-28 23:12:34 -05:00
Matthew Khouzam 58fa411ad3 Update objectsort.cpp 2018-11-28 23:11:57 -05:00
Matthew Khouzam 08c2449672 Update objectsort.cpp 2018-11-28 23:11:27 -05:00
Matthew Khouzam 726af82c56 objectsort: remove useless check
if an object is a ship, it is a model. No need
to check twice.
2018-11-28 20:41:45 -05:00
m!m c11dce4a92 Merge pull request #1939 from TheMatthew/clean-fast-path
objectsort: Move nebula detection to common area
2018-11-28 19:11:56 +01:00
Matthew Khouzam 0121eb6123 objectsort: Move nebula detection to common area
Run nebula test once per frame rather than once
per object.

Use a common function to avoid drifting errors.
2018-11-27 23:45:09 -05:00
niffiwan 8a325362f6 Merge pull request #1938 from asarium/fix/optionalScriptingParameters
Check optional scripting parameters before using them
2018-11-27 20:07:29 +10:00
asarium 4eb0e41142 Check optional scripting parameters before using them
These were all cases where the parameter was the new value when setting
a variable. The variables should always be initialized when that code is
reached but it is still better to check the pointers before using them.

These were found by @niffiwan.
2018-11-26 18:50:12 +01:00
Goober5000 5528e4e42d Merge pull request #1933 from Goober5000/multi_sexp_destroy_and_subsys
multi capability for destroy-instantly and destroy-subsys-instantly
2018-11-25 13:41:33 -05:00
Goober5000 968695f851 fix handling of multiplayer packets 2018-11-25 00:27:14 -05:00
Goober5000 8f00c6e842 since we switched from a while-loop to a for-loop, don't repeat the CDR 2018-11-25 00:27:14 -05:00
Goober5000 8a9edb1215 remove error_bypass from new function 2018-11-25 00:27:14 -05:00
Goober5000 1c9e47ad3d address clang-tidy complaints 2018-11-25 00:26:29 -05:00
Goober5000 74fd3c0637 multi capability for destroy-instantly and destroy-subsys-instantly
Previously, these two SEXPs could only be used in single-player; now they can be used in multiplayer.  (This now allows Admiral MS's ship save/load script to work in multiplayer too.)

Inspired by Parias's patch included in the FSPort Co-Op Mod Beta (https://www.hard-light.net/forums/index.php?topic=88385.0) though with some modifications.
2018-11-25 00:26:29 -05:00
Goober5000 fe0f0558c2 Merge pull request #1937 from Goober5000/remove_error_bypass
remove error bypass in subsys functions
2018-11-25 00:20:34 -05:00
Goober5000 11ded47bd5 qtfred too 2018-11-24 14:57:38 -05:00
Goober5000 f8801446db fix function references 2018-11-24 14:11:26 -05:00
Goober5000 7492615a31 remove error_bypass 2018-11-24 14:05:37 -05:00
m!m 53cfc1eae4 Merge pull request #1936 from niffiwan/fix/issue1935
Fixes issue #1935
2018-11-24 09:25:06 +01:00
niffiwan 252facb6c4 Merge pull request #1927 from asarium/fix/decalObjectTypeChanges
Add additional validity check for decals
2018-11-24 10:52:18 +10:00
niffiwan 65417be571 Fixes issue #1935
If the optional arg isn't present; just pass -1 to bm_set_render_target
2018-11-24 09:04:12 +10:00
Goober5000 0da41b3943 address clang-tidy complaint 2018-11-22 16:07:00 -05:00
plieblang 97f9a6c91b Set default lighting to cmdline params and add reset view 2018-11-22 13:40:05 -06:00
m!m 10cd82456d Merge pull request #1914 from Goober5000/small_collision_optimization
only recompute collision pairs if we moved a colliding object
2018-11-21 18:59:08 +01:00
Goober5000 7878ba0d19 only recompute collision pairs if we moved a colliding object
The code already only recomputed collisions if we moved a ship or a wing, but this further optimizes things so that only ships or wings that can collide will cause a recomputation.
2018-11-20 13:54:39 -05:00
Goober5000 a6879a1b40 remove warning 2018-11-20 13:49:50 -05:00
Goober5000 cf7706eb1c might as well add the extents functionality too 2018-11-20 13:49:50 -05:00
Goober5000 09ed127d06 fix typo 2018-11-20 13:49:50 -05:00
Goober5000 77c3c79143 update special-warp-dist 2018-11-20 13:49:50 -05:00
Goober5000 62b74b8743 upgrade position_ship_for_knossos_warpin 2018-11-20 13:49:50 -05:00
Goober5000 4d99a3b8b3 fix determination of dist_to_plane 2018-11-20 13:49:49 -05:00
Goober5000 3a9a840633 forgot one of these 2018-11-20 13:49:49 -05:00
Goober5000 86f67c3c84 warp should be pretty much working correctly now
precalculate warp values before beginning warp, and use them throughout the warp instead of recalculating in every function
standardize on always using the entire docked assembly for length and half-length calculation, instead of some places the assembly and some places just the dock leader
consolidate and simplify the compute_warpout* functions in light of the above
2018-11-20 13:49:49 -05:00
Goober5000 28bb3bf914 rewrite dock_calc_docked_center to find the true physical center of the docked assembly 2018-11-20 13:49:49 -05:00
Goober5000 bd4b116188 this should fix the warpin/warpout distances for regular warpin 2018-11-20 13:49:49 -05:00
Tyler Blount 0a429e8a32 Merge pull request #1931 from asarium/fix/qtAppveyorNightlies
Also fix Appveyor Qt path for nightly builds
2018-11-18 16:59:09 -07:00
asarium f70253e219 Also fix Appveyor Qt path for nightly builds 2018-11-18 19:45:32 +01:00
m!m e901e44418 Merge pull request #1881 from asarium/cleanup/adeSignature
Add proper class support to Lua API
2018-11-18 19:09:45 +01:00
asarium 651268eeea Fix rvalue reference issue in SetHookVar 2018-11-18 12:43:39 +01:00
asarium 9b7c32d0c1 Fix merge issue 2018-11-18 12:43:39 +01:00
asarium d014e53505 Fix clang-tidy issues 2018-11-18 12:43:39 +01:00
asarium 00b0a80ad9 Call scripting handle destructor when Lua collects garbage
This will automatically call the destructor of a type of Lua calls the
garbage collector for an object of that type. This is the last step
towards fully supporting non-trivial objects in the Lua API and all
previous workarounds have been removed.
2018-11-18 12:43:39 +01:00
asarium 4a7109e1d5 Convert scripting value getting to templates
This is pretty much similar to the value setting changes. This is a much
safer solution for getting values out of the scripting system which has
compile time validation for move-only types.
2018-11-18 12:43:39 +01:00
asarium 1484ddbe77 Convert scripting value setting to using placement-new
This commit changes the way the scripting API works by properly using
the newly available type information for moving the FSO resources into
the memory supplied by lua. This has full support for rvalue references
which will make it possible to use move-only types with the scripting
API.

This also makes the API much safer to use since it doesn't use pointers
to local values anymore which made it very hard to use the API in a
different context without causing issues.

This only covers writing the FSO values to Lua. Getting values back is
not covered yet.
2018-11-18 12:43:39 +01:00
asarium 48b03a1789 Remove ADE signature from scripting API
This was previously used for allowing scripts to set arbitrary values on
scripting objects. However, it was used by only a few scripting
functions and, as far as I know, no script uses this features.

This removes that feature which simplifies the code ade_index_handler
of.

This also simplifies the code that handles the userdata for libraries
provided by FSO.
2018-11-18 12:43:39 +01:00
asarium e790cf209a Add additional validity check for decals
This tracks the original object type of a decal and marks a decal as
invalid if the type changes. This should fix a bug reported by Spoon.
2018-11-18 12:41:55 +01:00
Tyler Blount 1eea298fe1 Merge pull request #1929 from TRBlount/fix/lab_insignia
Fix oversights when a mod has zero Insignias
2018-11-13 19:08:43 -07:00
TRBlount 1de63cc881 Make sure having no insignias doesn't trigger asserts and prevent insignias from being rendered 2018-11-13 14:57:22 -07:00
Tyler Blount c7be4734d3 Merge pull request #1930 from asarium/build/appveyorDebug
Fix Appveyor Qt directory
2018-11-13 14:55:19 -07:00
asarium fbc2a2dab2 Fix Appveyor Qt directory
They updated their Qt version and didn't update the documentation page.
This fixes the recent build errors by using the 5.9 symlink which is
linked to the most recent version.
2018-11-13 18:27:02 +01:00
Tyler Blount e5be2372e1 Merge pull request #1928 from TRBlount/fix/share_fire_dir_access
Fix access violation in ship_get_global_turret_gun_info
2018-11-12 21:06:21 -07:00
TRBlount 9c69e11fe5 Add requested changes 2018-11-12 17:56:50 -07:00
TRBlount 0173f44070 Fix access violation in share_fire_direction code path 2018-11-11 16:09:05 -07:00
Fabian Woltermann 45559c13a9 Merge pull request #1912 from asarium/cleanup/noOldCollision
Remove -old_collision command line option
2018-11-10 17:52:17 +01:00
Fabian Woltermann 34888cb1a6 Merge pull request #1923 from asarium/cleanup/speechAPI
Cleanup the speech API code a bit
2018-11-10 17:51:32 +01:00
Fabian Woltermann b77b425f2f Merge pull request #1920 from The-E/feature/lab_camera_controls
Make the lab camera better
2018-11-10 17:40:51 +01:00
Fabian Woltermann 49b5c10295 Addresses feedback, switches default rotation mode to "Both" 2018-11-07 17:13:11 +01:00
niffiwan 0396d5670b Merge pull request #1924 from tomimaki/fix-incomplete-fb-attachment
Fix for incomplete attachment in shadow framebuffer
2018-11-07 07:54:12 +10:00
tomimaki bb6c00a516 Update gropengltnl.cpp 2018-11-06 15:13:59 +01:00
Fabian Woltermann 4d0703ad98 Remove the "disabled" rotation mode 2018-11-04 12:06:00 +01:00
asarium 27e91d8f6c Cleanup the speech API code a bit
This replaces the previously used defines with inline functions which
fixes a few warnings if the macros were ever used. This also changes
fsspeech.cpp so it is compiled always since it has no dependency on the
underlying speech system.
2018-11-03 14:54:29 +01:00
Fabian Woltermann 3c4ab2eef1 Add roll controls 2018-11-03 10:34:17 +01:00
Fabian Woltermann 4e7f29ea88 MORE CI fixes 2018-11-03 10:34:17 +01:00
Fabian Woltermann 793a3d8dd3 Even more CI fixes 2018-11-03 10:34:16 +01:00
Fabian Woltermann 49abb88385 Avoid CI errors 2018-11-03 10:33:06 +01:00
Fabian Woltermann 4c2ed1501e Switch the model rotation controls to a "turntable" model, add constraints, make speed configurable 2018-11-03 10:33:06 +01:00
Fabian Woltermann 6b425c1e6b Merge pull request #1922 from asarium/fix/1921
Fix cubemap offset computation for texture uploads
2018-11-03 10:27:58 +01:00
m!m 978a58dba2 Merge pull request #1917 from plieblang/LabArrowScrolling
Add arrow key scrolling to the lab
2018-11-03 09:07:20 +01:00
plieblang 3de05aefef Fire the item's existing function when selected 2018-11-03 01:21:47 -05:00
asarium da951e8be4 Fix cubemap offset computation for texture uploads
The changes from #1752 changed how the offset was computed but the
cubemap code did not update the initial offset computation to account
for this.

This fixes #1921.
2018-11-02 17:33:16 +01:00
m!m 483a6096bb Merge pull request #1885 from ngld/fix/rocketUI/tooMuchSound
Only play UI sounds if the event is triggered on the element where the property is set.
2018-10-31 19:14:19 +01:00
ngld 0ac810e7f0 Only play UI sounds if the event is triggered on the element where the property is set. 2018-10-31 06:46:27 +01:00
plieblang 0de1e55fb7 CI feedback 2018-10-28 17:25:43 -05:00
plieblang 3827bb9783 Fix nullptr crash and use vectors for *_list_endpoints 2018-10-28 12:59:36 -05:00
plieblang 69013f1d41 Add arrow key scrolling to the lab 2018-10-28 12:31:12 -05:00
m!m 3ac7864ac6 Merge pull request #1752 from asarium/opengl/baseLevelImprovement
Only upload mipmap levels that are actually needed
2018-10-28 18:22:01 +01:00
asarium 35a654660f Only upload mipmap levels that are actually needed
Previously, the game uploaded all mipmap levels found in the image files
and then selected which ones it will use by using GL_TEXTURE_BASE_LEVEL.
This unnecessarily used additional GPU memory which is especially bad if
the player already needs to use a lower detail level. This fixes that by
only uploading the necessary mipmap levels.
2018-10-28 14:57:00 +01:00
Goober5000 f975edd343 Merge pull request #1911 from asarium/feature/noSubsystemSparks
Add option for disabling spark spawning for subsystem
2018-10-27 12:50:50 -04:00
asarium 9219712ff0 Add option for disabling impact debris spawning 2018-10-27 16:37:42 +02:00
plieblang ead6cd9825 Separate ships by species properly 2018-10-26 00:21:08 -05:00
Goober5000 a32c5dad27 Merge pull request #1913 from Goober5000/whack_from_center_of_mass
calculate physics whack from docked center-of-mass, not docked center
2018-10-25 15:42:25 -04:00
plieblang 34d4ed5dba Scroll through ships/weapons with up/down keys 2018-10-25 11:50:16 -05:00
Goober5000 eb012584d6 Merge pull request #1880 from Goober5000/play_dead_persistent
add ai-play-dead-persistent
2018-10-24 14:50:40 -04:00
Goober5000 7cadce113d calculate physics whack from docked center-of-mass, not docked center 2018-10-24 00:17:10 -04:00
Goober5000 17b01fa8eb Merge pull request #1906 from plieblang/LabShipMenuImprovement
Show ship directly when clicking on it in the F3 lab
2018-10-23 22:41:16 -04:00
Goober5000 45ea62a9a2 Merge pull request #1907 from plieblang/ShipInvisibleAutoTargeting
ship-invisible doesn't turn off autotargeting
2018-10-23 22:41:02 -04:00
plieblang 979a4b0924 Flip default param value 2018-10-22 14:42:42 -05:00
Goober5000 e1db71fb69 Merge pull request #1910 from wookieejedi/FixOnShipDepart
Fix to "On Ship Depart" to incorporate Goober's feedback
2018-10-22 14:27:03 -04:00
niffiwan c33d406942 Merge pull request #1909 from asarium/build/travis_windows
Test Windows compilation with Travis CI
2018-10-22 22:03:25 +10:00
plieblang 30baac39a9 Combine cease_targeting functions 2018-10-21 13:13:08 -05:00
asarium 15dc45cc0a Remove -old_collision command line option
The new system has been tested pretty thoroughly so I think it is time
to remove this option.
2018-10-21 18:36:59 +02:00
asarium 3c41b56449 Add option for disabling spark spawning for subsystem
This adds the "no sparks" flag for subsystems which disables the
generation of spark sources for that subsystem when it is hit.

This was requested by Axem.
2018-10-21 18:03:48 +02:00
wookieejedi 50dbbc4687 Incorporates Goober's feedback
Moved new "On Ship Depart" hook exectuion to ship_cleanup.
2018-10-21 01:11:16 -04:00
niffiwan e19a6f9e01 Merge pull request #1905 from wookieejedi/OnDepartHook
Add '$On Ship Depart' Conditional Hook
2018-10-21 08:52:53 +10:00
niffiwan d9184545f7 Merge pull request #1902 from plieblang/BriefingVoiceUnpause
Play simulated speech if mission is launched while briefing is paused
2018-10-21 08:52:18 +10:00
asarium 5c07d181ad Test Windows compilation with Travis CI
Travis CI recently added support for running builds in Windows. This
adds support for testing compilation on Windows using that feature.

The newer version of Visual Studio and MinGW required some code changes
and an update of Google Test which is included in this commit.
2018-10-20 23:44:10 +02:00
wookieejedi 140fed2812 Added "Method" hook variable to "On Ship Depart" 2018-10-20 16:41:59 -04:00
plieblang dd2fd3ee5c Address feedback 2018-10-20 10:45:51 -05:00
plieblang dd7c36e43d ship-invisible doesn't turn off autotargeting 2018-10-19 18:49:53 -05:00
plieblang 409c7da2d7 Clicking on a ship in the lab shows it directly 2018-10-19 15:00:07 -05:00
wookieejedi 791e22bc1d Add On Ship Depart Conditional Hook 2018-10-18 17:50:22 -04:00
plieblang 6a93715c9b Clarify fsspeech_pause call 2018-10-18 11:28:45 -05:00
Goober5000 8fee9804df Merge pull request #1903 from plieblang/LabUpdatePOFName
Update displayed POF name in the F3 lab when new ship is selected
2018-10-17 23:32:53 -04:00
plieblang 2dc6d64c37 Update POF name when new ship is selected 2018-10-17 19:31:37 -05:00
plieblang a8142b8f80 Solution that actually compiles 2018-10-17 15:56:12 -05:00
plieblang 53f98cda99 Play simulated speech if mission is launched while briefing is paused 2018-10-17 01:03:39 -05:00
m!m 115d06a051 Merge pull request #1899 from Artyrm/Fix_missing_HUD
Fix missing HUD bug
2018-10-14 19:22:37 +02:00
m!m 485af1bad3 Merge pull request #1895 from Artyrm/Adapt_barracks_interface
Barracks stats adaptation for longer Unicode strings.
2018-10-14 19:22:27 +02:00
Goober5000 0ca5ade5ef Merge pull request #1894 from Artyrm/master
More friendly assert if used font misses a glyph.
2018-10-14 13:22:05 -04:00
Artyrm ff601db6fc Switched to hud_config_as_player() 2018-10-14 18:15:18 +03:00
Artyrm 686bc35cff Moved variables, gave mean. names and descr. 2018-10-14 16:07:59 +03:00
Artyrm ffe9a085b6 Improved readability. 2018-10-14 15:39:48 +03:00
Artyrm 33df766edf #ifdefed debug parts. 2018-10-14 15:25:17 +03:00
Artyrm 9a6227e7b0 Fixed grammar. 2018-10-14 14:58:53 +03:00
m!m c664eac1ee Merge pull request #1898 from ngld/enhance/betterBmErrors
If an icon can't be loaded, display an error instead of asserting.
2018-10-14 12:31:03 +02:00
Artyrm a7a9514fd1 Little cleanups. 2018-10-13 19:37:17 +03:00
Artyrm b402d9158c Use .is_observer flag. Add HUD restore in DEBRIEF state. 2018-10-13 18:56:21 +03:00
Artyrm c1b055a685 Start using hud_config_restore(). 2018-10-13 16:58:17 +03:00
ngld 412197d3e9 Gracefully handle missing briefing icons. 2018-10-13 06:16:16 +02:00
Artyrm 98f1d690f6 Fix Clang warnings. 2018-10-12 19:18:24 +03:00
Goober5000 842dbb1b75 Merge pull request #1888 from plieblang/AIProfileABFlag
Add "$free afterburner use" flag to ai_profiles.tbl
2018-10-12 12:12:26 -04:00
Artyrm df8e85f22e String width adapts, orig. behaviour is intact. 2018-10-12 17:57:44 +03:00
Goober5000 73482a6d62 Merge pull request #1896 from wookieejedi/FixOnArriveforDockWings
Fixes missing "On Ship Arrive" with Docked Wings
2018-10-11 22:38:04 -04:00
wookieejedi afa7976018 Removed redundant syntax 2018-10-11 18:36:05 -04:00
wookieejedi 0d355982d4 Update code/mission/missionparse.cpp 2018-10-11 11:43:40 -04:00
wookieejedi 7f9021cbdb Fixed missing "=" 2018-10-11 11:41:53 -04:00
wookieejedi 1450c71e2e Improve dock check with bool
Uses boolean value to determine if wing is docked, incoroprates that bool into if block for setting On Ship Arrive hook.
2018-10-11 11:39:16 -04:00
wookieejedi d80e6d0f71 Fixed missing "_" 2018-10-10 18:05:48 -04:00
wookieejedi f6dd3b09ab Remove incorrect placement 2018-10-10 17:05:22 -04:00
wookieejedi bc5ef0b28d Fixed anchor call and null bug 2018-10-10 13:12:18 -04:00
wookieejedi 8e618ffaec Add HV to Docked Wings
Fixs bug by adding the conditional hook call "On Ship Arrive" to docked wings that arrive.
2018-10-10 12:24:30 -04:00
Artyrm 889474688c Barracks stats adaptation for longer Unicode strings. 2018-10-10 18:01:06 +03:00
Artyrm d56cb8fc62 Even mor specific, gcc syntax. 2018-10-09 19:29:00 +03:00
Artyrm 98f196ee48 Compiler-specific fallthrough. 2018-10-09 19:13:36 +03:00
Artyrm 9f4ad9d1eb #ifdefed print for Release. Tried the strictest fallthrough comment 2018-10-09 18:29:00 +03:00
Artyrm a69e1d7308 Proper args handling. Extern C is also back. 2018-10-09 17:48:42 +03:00
Artyrm 34d1bf03f9 Got rid of unnes. #ifded. 2018-10-09 17:28:03 +03:00
wookieejedi 9fcd96ff97 Adds Accept Mission Outcome as new Conditional Hook (#1893)
* Adds Accept Mission Outcome Event to Game Events

Adds Accept Mission Outcome Event to Game Events, so scritps and other things can be called only when a campaign mission is accepted.

* Fixed double entry

* Define CHA_CMISSIONACCEPT

Adds line to define new conditional hook, CHA_CMISSIONACCEPT

* Add flag_def_list for On Campaign Mission Accept

Adds the proper flag_def_list for "On Campaign Mission Accept" CHA_CMISSIONACCEPT

* Runs New Conditional Hook

Runs the new conditional hook for "On Campaign Mission Accept"

* Reverts event changes

* Reverts state changese

* Reverts post_event change
2018-10-08 18:13:02 +02:00
Artyrm 2b77721c79 Tweaked function type a little for compilers. 2018-10-08 12:45:14 +03:00
Artyrm 95fafa50c4 Changed printf function. Explicit fallthrough. 2018-10-08 12:01:55 +03:00
Artyrm cac07391ca More user-friendly assert on missed glyph in font. 2018-10-07 23:44:27 +03:00
Goober5000 9daeb7f417 Merge pull request #1891 from Artyrm/master
Switch communication messages to use SCP_string
2018-10-07 11:11:06 -04:00
Artyrm f0ba0265fd New version of stb_truetype.h, just in case. 2018-10-07 15:35:12 +03:00
Artyrm 5b77cad5ac Merge branch 'ComMsg_Unicode_fix' 2018-10-07 14:57:16 +03:00
Artyrm 3f024cb324 And FRED fix as well. 2018-10-07 14:56:50 +03:00
m!m 1d60d25cf5 Merge pull request #1890 from wookieejedi/HyperspaceSounds
Fix missing Warpin sounds from Hyperspace Warpin Effect
2018-10-07 09:36:16 +02:00
Artyrm be5c98c7e2 Merge branch 'ComMsg_Unicode_fix' 2018-10-06 19:57:36 +03:00
Artyrm 6212ad29f1 One dependency in qtfred. Fixed. 2018-10-06 19:57:06 +03:00
wookieejedi 5ec30bdaee Update code/ship/shipfx.cpp 2018-10-06 11:37:50 -04:00
wookieejedi b9b74a3201 Fixed sound variable error
Pos variable not used, so removed it.
2018-10-06 09:45:36 -04:00
wookieejedi 09c24313d7 Added sounds to WE Hyperspace
Allows warpin enter and exit sounds to be properly used with the Hyperspace warpin effect.
2018-10-06 08:35:28 -04:00
Artyrm afdaa3a3ee Merge branch 'ComMsg_Unicode_fix' 2018-10-06 13:32:20 +03:00
Artyrm 68dcef639d Clean-up commented variants. 2018-10-06 13:31:21 +03:00
wookieejedi 91f351b990 Update code/ship/shipfx.cpp 2018-10-06 01:35:52 -04:00
wookieejedi dd1def4f4c Update code/ship/shipfx.cpp 2018-10-06 00:36:23 -04:00
wookieejedi 8b770792fb Update code/ship/shipfx.cpp 2018-10-05 22:17:30 -04:00
plieblang 23f9cfc815 Add free-afterburner-use flag to ai_profiles.tbl 2018-10-02 14:10:27 -05:00
niffiwan 11f9175425 Merge pull request #1887 from TRBlount/feature/mod_play_warp_settings
Make player warpout settings customizable
2018-10-01 11:08:14 +10:00
Artyrm 4fb9c27e71 Comm_orders assign fix. MsgItems to SCP_string too. 2018-09-30 23:51:47 +03:00
TRBlount 4c7b7a0fef Make player warpout settings customizable 2018-09-30 11:31:41 -06:00
Artyrm 3dc1689936 Switched to SCP_string in HUDSquadMsg 2018-09-30 17:23:23 +03:00
niffiwan 94df2777e0 Merge pull request #1884 from niffiwan/fix/setetsvalues_doco
Fix set-ets-values sexp documentation bug
2018-09-30 12:52:38 +10:00
niffiwan c9ebc33d98 apply similar to get-ets-values 2018-09-30 10:12:18 +10:00
niffiwan 9bd459d549 further enhance doco (per feedback) 2018-09-30 09:27:10 +10:00
m!m d9db8bdb71 Merge pull request #1883 from asarium/fix/linuxRelease
Fix linux release building
2018-09-29 16:30:46 +02:00
niffiwan f3cdfcc229 Fix set-ets-values sexp documentation bug
Found by Asteroth - thanks!
2018-09-29 19:16:06 +10:00
asarium 44e3f1f9b5 Fix linux release building
I removed too much code when disabling qtFRED deployment...
2018-09-29 10:30:15 +02:00
niffiwan da5e7f1510 Merge pull request #1882 from asarium/build/disableLinuxQtFred
Disable Linux qtFRED building again
2018-09-29 10:51:55 +10:00
asarium d830a01381 Disable Linux qtFRED building again
There are still some unresolved issues and the file size is pretty large
due to some issues with how the AppImage is built.
2018-09-28 23:13:20 +02:00
m!m d24d536731 Merge pull request #1862 from asarium/feature/libRocket
Add scripting features for barracks libRocket UI
2018-09-28 10:27:01 +02:00
Goober5000 6d0e166dea Merge pull request #1875 from asarium/opengl/shadowFboFix
Remove duplicate shadow FBO creation
2018-09-27 16:34:33 -04:00
m!m e0301da596 Merge pull request #1879 from Goober5000/fred_choose_dock_leader
always choose a dock leader in FRED
2018-09-27 11:46:55 +02:00
asarium a815c0247c Add scripting features for barracks libRocket UI
This mostly adds the scripting features required for accessing the
various internal variables required for the barracks screen.
2018-09-27 11:45:09 +02:00
m!m f42eaf9637 Merge pull request #1817 from asarium/cleanup/luaVarargs
Convert scripting interaction function to variadic templates
2018-09-27 11:44:22 +02:00
Goober5000 c667668c17 don't override play-dead goals 2018-09-27 01:33:44 -04:00
Goober5000 8d4643bc7a add ai-play-dead-persistent
This adds a new AI goal which is equivalent to play-dead except that it "sticks".  It doesn't clear the goal list
so it will continue playing dead until the goal is removed or another goal with a higher priority is added.
2018-09-27 00:48:57 -04:00
Goober5000 01fb2c1243 Merge pull request #1878 from Goober5000/fireball_warp_type
allow custom fireballs to be used as ship warp effects
2018-09-26 17:21:29 -04:00
Goober5000 408f259368 always choose a dock leader in FRED
In FRED, if all docked ships had their arrival cue set to false, none of them would be loaded
in the mission because there was no dock leader to bring in the entire group.  This PR fixes that
by choosing an arbitrary ship (the biggest ship according to ship_class_compare) to be the
dock leader.  This consequently fixes issue #1877 because the wing is able to find its ship.
2018-09-26 15:35:23 -04:00
Goober5000 a9b8e5c043 address clang-tidy complaints 2018-09-26 14:17:39 -04:00
asarium cfb9540e2c Fix issues with ignoring parameters 2018-09-26 19:15:42 +02:00
asarium 88115c7703 Fix clang-tidy issues 2018-09-26 19:15:42 +02:00
asarium 8dba6770ae Convert ade argument setting to variadic templates
Same as with argument getting, this preserves the type information and
makes the system generally much safer.
2018-09-26 19:15:42 +02:00
asarium 8f4d51b14a Convert ade_get_args to variadic template based solution
This maintains the type information which can be used for enforce
const-correctness and also for implementing more advanced ways of
handling the type information.
2018-09-26 19:15:42 +02:00
asarium 185aece470 Remove duplicate shadow FBO creation
This appears to be a leftover from the development of the shadow
rendering code. The shadow FBO was allocated twice but only one was
used. This removed the unused code and also ports the improved error
handling of that code over to the actual shadow FBO creation code.
2018-09-26 14:10:35 +02:00
m!m 0e962e269b Merge pull request #1876 from plieblang/MemUsageFlagRemoval
Don't show nonexistent memory usage flag
2018-09-26 09:02:20 +02:00
Goober5000 095a2efc56 allow custom fireballs to be used as ship warp effects
This allows the WE_Default warp type to be used with any warp fireball in fireball.tbl.  The fireball can be used by specifying its unique ID for the existing $Warpin type and $Warpout type options in ships.tbl.  The warp type is managed by bitwise-OR'ing a flag to the fireball's index.
2018-09-26 00:19:17 -04:00
plieblang 944a254551 Don't show nonexistent memory usage flag 2018-09-25 16:37:21 -05:00
Goober5000 f628999ef9 Merge pull request #1872 from asarium/fix/libRocketTTF
Disable libRocket unless unicode mode is active
2018-09-24 12:02:33 -04:00
Goober5000 e2fb4d84d7 Merge pull request #1871 from asarium/fix/linuxBuildTransferSh
Remove release build uploading to transfer.sh
2018-09-23 19:59:38 -04:00
asarium ff952298a2 Disable libRocket unless unicode mode is active
Since libRocket requires unicode mode this doesn't change anything but
it fixes an error when a mod uses TrueType fonts without unicode mode.
2018-09-23 14:18:35 +02:00
m!m 66b3fdfed8 Merge pull request #1870 from Goober5000/issue_1869
fix issue #1869
2018-09-23 12:19:41 +02:00
asarium 451c03f76a Remove release build uploading to transfer.sh
I think I used that for debugging some things but now it's causing
issues.
2018-09-23 12:16:12 +02:00
Goober5000 da30c5a38e fix issue 1869 2018-09-22 18:33:00 -04:00
m!m 5206aaabdf Merge pull request #1866 from Goober5000/custom_warpglow
Custom warp glows, balls, and models
2018-09-20 23:20:34 +02:00
Goober5000 f6ed93f7a9 address Travis complaint 2018-09-20 15:29:05 -04:00
Goober5000 4f0e2ae9f1 additional small fixes 2018-09-20 00:25:42 -04:00
Goober5000 c3f595ba0e tweaks 2018-09-19 22:51:57 -04:00
Goober5000 d02d98681a apply new warp attributes for remodularized fireball.tbl 2018-09-19 20:08:19 -04:00
Goober5000 98e37b2570 Merge pull request #1865 from Goober5000/remodularize_fireball_tbl
Remodularize fireball.tbl
2018-09-19 19:50:18 -04:00
Goober5000 3c8b87c958 address PR feedback 2018-09-19 13:00:05 -04:00
niffiwan 8d44946b2b Merge pull request #1863 from asarium/fix/jsonPilotModConversion
Use the correct location flags for enumerating pilots
2018-09-19 21:24:08 +10:00
Goober5000 98b9d5c899 a few more corrections 2018-09-18 19:43:11 -04:00
Goober5000 2f5079fcd1 populate the fireball entry IDs when fred2 starts up
fix various issues with both strings and positive numbers being accepted as sexp arguments
2018-09-18 17:33:45 -04:00
asarium 59a8a347a1 Use the correct location flags for enumerating pilots
This was an oversight in the JSON changes since those were made long
before the CFile location flags were a thing. This uses the correct
location flags for enumerating pilots for conversion.
2018-09-18 22:33:51 +02:00
niffiwan e04f1b4ca4 Merge pull request #1861 from Artyrm/master
Training messages fix.
2018-09-18 20:08:19 +10:00
Fabian Woltermann 7da41c32e3 Merge pull request #1267 from asarium/feature/jsonPilotReading
Add JSON pilot reading implementation
2018-09-18 10:26:07 +02:00
Goober5000 73770845b6 use enhanced fireball.tbl to create OPF_FIREBALL for use in explosion-effect and warp-effect 2018-09-18 00:56:38 -04:00
Goober5000 5828d7f634 generate a unique ID for each fireball, if one isn't specified 2018-09-17 23:06:04 -04:00
Goober5000 45f6cdc687 make fireball modular tables simpler, without using the confusing lod_checker logic, and also add an optional unique id 2018-09-17 22:49:23 -04:00
Artyrm 13fe34a3c7 Merge branch 'training_messages_fix' 2018-09-17 22:26:33 +03:00
asarium da64f285bc Fix issue with file location flags 2018-09-17 20:12:38 +02:00
asarium 45f9ea2ea4 Suppress false-positives in valgrind tests 2018-09-17 19:47:40 +02:00
asarium eb73328c14 Add std::ostream operator to ID class
This will print the internal valie to the stream which can be useful for
debugging.
2018-09-17 19:24:20 +02:00
asarium 380ca12b0d Fix clang-tidy issues 2018-09-17 19:24:11 +02:00
asarium c7e66e26fb Delete old pilot files as well when deleting a pilot 2018-09-17 19:23:18 +02:00
asarium ff911e666d More fixes
This finally fixes the seemingly non-deterministic failure of the
unit-tests (among other things).
2018-09-17 19:23:12 +02:00
asarium c8619ddd0d Fix uninitialized variable error detected by valgrind 2018-09-17 19:23:05 +02:00
asarium 721b2da37b Fix copy-paste error
This caused the continuous conversion of old binary pilots to the JSON
format which reset all the changes made to the JSON data.
2018-09-17 19:22:59 +02:00
asarium e9f4c1618e Add unit tests for validating pilot loading 2018-09-17 19:22:50 +02:00
asarium 4eef54c10b Add JSON reading implementation
This changes the pilot reading code to always use JSON files for storing
the pilot data. Old pilots are converted to the new format when FSO
starts and after that point only JSON pilots will be used.
2018-09-17 19:22:43 +02:00
Artyrm f5ba1e470c Training messages fix. Their delay could be too small with voices volume ste to 0. 2018-09-17 20:12:58 +03:00
asarium 94a00ca6ee Add reading code to FileHandler
Currently only implemented for the BinaryFileHandler
2018-09-17 19:06:50 +02:00
Goober5000 3a8c10bec5 Merge pull request #1858 from Goober5000/enhanced_warp_effect
add additional parameters to warp-effect
2018-09-17 13:00:28 -04:00
niffiwan e92cc5161e Merge pull request #1859 from asarium/feature/loopingParticles
Add support for looping particles
2018-09-17 19:47:26 +10:00
asarium ea73ea33ca Add support for looping particles
This introduces support for keeping particles around forever and letting
them be controlled by a Lua script.
2018-09-17 09:26:20 +02:00
Goober5000 8fe7dc4a1b Merge pull request #1860 from Goober5000/friendlier_warning
rewrite the mod warning dialog a bit
2018-09-16 19:33:58 -04:00
Goober5000 f5bbb21199 rewrite the mod warning dialog a bit 2018-09-16 14:16:57 -04:00
Goober5000 c2761a6142 address clang-tidy complaints 2018-09-16 13:44:38 -04:00
Fabian Woltermann 88b0dba208 Merge pull request #1466 from asarium/feature/libRocket
Add new libRocket UI system
2018-09-16 15:20:34 +02:00
asarium 7173299ca7 Add new libRocket UI system
This new system allows to create a user interface that goes beyond the
existing UI system.
2018-09-16 13:55:29 +02:00
Fabian Woltermann e35fc10530 Merge pull request #1856 from Goober5000/sexp_reset_post_effects
add reset-post-effects sexp
2018-09-16 10:43:39 +02:00
Goober5000 46e8e735b6 more complaining by clang-tidy 2018-09-16 00:31:58 -04:00
Goober5000 e3e40ee576 fix build warning 2018-09-15 23:42:29 -04:00
Goober5000 f0b99e24ff add additional parameters to warp-effect
The warp-effect SEXP can now specify other animations from fireball.tbl that are not necessarily the standard or Knossos animations.  Additionally, the SEXP can now specify the duration for the opening and closing of the warp effect.
2018-09-15 23:30:17 -04:00
Goober5000 e0f76e0cfa tweak sexp documentation as well 2018-09-14 21:59:05 -04:00
Goober5000 5303440dfb add reset-post-effects sexp
Nobody ever thought to add a reset-post-effects SEXP to complement set-post-effects, so this remedies that.  Also, a few minor edits were made to the scripting documentation.
2018-09-14 21:54:35 -04:00
Fabian Woltermann 138a1d01d4 Merge pull request #1854 from TRBlount/fix/share_fire_dir
Fix share_fire_direction logic
2018-09-11 08:04:40 +02:00
TRBlount 0814bf0ae1 Fix share_fire_direction logic 2018-09-10 16:40:36 -06:00
niffiwan 39a0cfecbb Merge pull request #1853 from asarium/feature/sdlVersionDebugLog
Write SDL version to debug log
2018-09-10 23:31:03 +10:00
asarium b78d940136 Write SDL version to debug log
This adds the runtime and compile version of the used SDL library to the
start of the debug log. This was requested by ngld and should make
diagnosing some errors easier.
2018-09-10 09:36:24 +02:00
Goober5000 bc03442a3c Merge pull request #1850 from asarium/fix/1722
Handle DIRECTIVE_WING_ZERO in is-destroyed SEXPs correctly
2018-09-07 12:33:43 -04:00
asarium 8ce1a6f490 Handle DIRECTIVE_WING_ZERO in is-destroyed SEXPs correctly
The special value DIRECTIVE_WING_ZERO (defined to be -999) is used to
signify to the directives system that an is-destroyed SEXP was found
which specified an empty wing. However, if a second is-destroyed-delay
SEXP is present in the same directive then the count of the parameters
is added to -999 which makes means that the directives system then
displays it on the HUD as a negative number.

This fixes that by resetting the counter to 0 if a second SEXP
encounters the special value which fixes the issue in the supplied test
mission. There are probably other edge cases when using multiple
is-destroyed SEXPs in a directive so I added a warning to the SEXP help
which lets the mission designer know that it is preferable to specify
multiple parameters instead of using multiple is-destroyed SEXPs.

This fixes #1722.
2018-09-07 13:38:10 +02:00
Fabian Woltermann 18d2ef8580 Merge pull request #1849 from asarium/fix/1655
Apply clipping offsets when using the line draw list
2018-09-06 12:29:17 +02:00
asarium 4a86b70a69 Apply clipping offsets when using the line draw list
This should make the line draw list class behave identically to the old
line rendering functions. This caused a few issues where the lines were
drawn outside the scissor area which made them invisible.

This fixes #1655.
2018-09-04 15:04:57 +02:00
m!m f717c41083 Merge pull request #1846 from asarium/fix/nebulaBackground
Fix nebula background rendering
2018-09-02 22:59:59 +02:00
asarium 92aacc8479 Fix nebula background rendering
This makes the deferred fog rendering code use the nebula background
instead of the single fog color for the background.

This is not an ideal solution since objects fade to the fog color
instead of the color of the background but it's better than rendering no
background.
2018-09-02 19:07:48 +02:00
Fabian Woltermann 2ae7990c61 Merge pull request #1845 from asarium/fix/1828
Disable movie looping for MVE cutscenes
2018-09-02 15:53:38 +02:00
asarium 4e8ebedfa0 Disable movie looping for MVE cutscenes
This changes the FFmpeg code to not use av_seek_frame anymore if looping
is not required. This fixes an issue when playing MVE movies since that
format does not support seeking.

This fixes #1828.
2018-08-30 23:10:22 +02:00
m!m 01f418f2fb Merge pull request #1844 from The-E/fix/hdr_spec_maps
HDR color space conversion for spec maps is not applied correctly
2018-08-30 15:52:03 +02:00
Fabian Woltermann 0ed47de357 Update main-f.sdr 2018-08-30 13:53:20 +02:00
Fabian Woltermann f5f1c97c0f HDR color space conversion for spec maps only happened in one code path, not all of them. This fixes that. 2018-08-29 21:19:48 +02:00
Goober5000 b0d3957df7 Merge pull request #1841 from niffiwan/feature/per_ship_scan_range
add per-ship-class scanning range feature
2018-08-28 12:59:07 -04:00
niffiwan 332bd01f0f address feedback
remove static keyword & add comment for new constant variable
switch to using #define values for the default scan ranges
2018-08-28 21:51:06 +10:00
niffiwan eb8717f051 add per-ship-class scanning range feature
Requested for FotG - allow dedicated scanning ship options
e.g. Y-wing Longprobe & TIE/rc
2018-08-28 21:13:50 +10:00
m!m af8ae03d9e Merge pull request #1839 from Goober5000/ignore_multiplayer_campaigns
ignore multiplayer as well as singleplayer campaigns
2018-08-24 18:41:53 +02:00
Goober5000 0ca7299bbc ignore multiplayer as well as singleplayer campaigns 2018-08-24 10:58:11 -04:00
Fabian Woltermann 98234c3bc2 Merge pull request #1834 from The-E/fix/team_color_srgb
The team color process is only valid for srgb color space
2018-08-23 18:53:36 +02:00
niffiwan 50691c41da Merge pull request #1837 from niffiwan/feature/autoaim_frame
add feature: change reticle when autoaim is active
2018-08-22 08:42:08 +10:00
m!m 4a66cb190a Merge pull request #1824 from The-E/fix/vm_vec_random_cone_params
vm_vec_random_cone needs to be called with the smaller angle first.
2018-08-21 15:04:39 +02:00
niffiwan 9ba3a0ccf9 clang-tidy: remove FALSE & NULL 2018-08-21 22:53:31 +10:00
niffiwan b625f51645 add feature: change reticle when autoaim is active
Optionally play a sound when autoaim becomes active, and another sound
when autoaim becomes inactive
Credit to zookeeper - I'm just pushing this into master!
2018-08-21 20:56:58 +10:00
Fabian Woltermann c2c8acbf13 REdo properly 2018-08-20 17:12:38 +02:00
Fabian Woltermann ac58950ac5 Revert "vm_vec_random_cone needs to be called with the smaller angle first."
This reverts commit 5b01036723.
2018-08-20 17:10:31 +02:00
Fabian Woltermann 8a84fffe12 Small copy/paste error fix 2018-08-19 20:18:31 +02:00
Fabian Woltermann 0c216ede98 The team color process is only valid for srgb color space, so we need to convert everything into it when we do the thing 2018-08-19 20:14:15 +02:00
m!m 3e543729fc Merge pull request #1832 from Goober5000/ignored_missions
add game_settings feature to ignore single missions
2018-08-19 16:39:49 +02:00
Goober5000 6385bf73be we should not only match without regard to file extension but also without regard to letter case -- and do this for campaigns as well 2018-08-18 15:20:04 -04:00
Goober5000 b7a32329db Merge pull request #1831 from Goober5000/make_getmissionfilename_consistent
make sure getMissionFilename never has a .fs2 extension
2018-08-18 15:05:06 -04:00
m!m b363bda60d Merge pull request #1833 from Goober5000/fix_insufficient_loadout_crash
fix bug introduced in pr #1736
2018-08-18 09:08:23 +02:00
Goober5000 0b547d971e make sure getMissionFilename never has a .fs2 extension 2018-08-18 01:52:48 -04:00
Goober5000 9ac04b9349 fix bug introduced in pr #1736 2018-08-18 01:35:16 -04:00
Goober5000 453b1ca619 address clang-tidy complaint 2018-08-17 23:16:48 -04:00
Goober5000 e6f1332980 add game_settings feature to ignore single missions 2018-08-17 18:32:58 -04:00
Goober5000 5840ca84d6 make sure getMissionFilename has a .fs2 extension 2018-08-17 16:47:51 -04:00
m!m aa0e1c755f Merge pull request #1825 from niffiwan/feature/qtfred_asteroid
qtfred asteroid editor
2018-08-17 13:37:26 +02:00
niffiwan 97469d65ef Merge pull request #1820 from asarium/build/updatedFFmpeg
Update prebuilt FFmpeg libraries to version 3.4.4
2018-08-17 19:24:11 +10:00
niffiwan 5834c01ca9 use UNREACHABLE macro in switch default:
addresses review feedback from m!m
2018-08-14 19:50:08 +10:00
niffiwan 13076364d6 Merge pull request #1714 from asarium/qtfred2_/linuxqtdeploy
Enable qtFRED for all deployments
2018-08-13 23:38:07 +10:00
niffiwan e2905e76ca fix clang-tidy (3): const auto & (!) ;) 2018-08-13 19:09:47 +10:00
niffiwan accea7bb4d fix clang-tidy warnings (2): const auto 2018-08-12 22:39:52 +10:00
niffiwan 733b67ada3 fix clang-tidy warnings
change CLAMP macro to use boolean rather than implicit conversion int
2018-08-12 21:42:11 +10:00
niffiwan de06d1e36f fix clang-tidy warnings (1)
add override to functions
convert to range based for loops
set default dtor
2018-08-12 21:40:47 +10:00
niffiwan 7e6eb25492 triple braces clang? really? 2018-08-11 22:37:57 +10:00
niffiwan 9de5d8d011 add asteroid editor to qtfred 2018-08-11 20:49:55 +10:00
Fabian Woltermann 62d178d896 Merge pull request #1818 from asarium/feature/loopingMovies
Add support for looping movies
2018-08-10 20:46:36 +02:00
Fabian Woltermann f8b210b659 Merge pull request #1819 from asarium/feature/vec3dOperators
Add C++ operators for vector math operations
2018-08-10 20:45:45 +02:00
Fabian Woltermann d3e6ee81e1 Merge pull request #1822 from asarium/fix/fredFlags
Terminate FRED/qtFRED when command line demands it
2018-08-10 20:44:56 +02:00
Fabian Woltermann 5b01036723 vm_vec_random_cone needs to be called with the smaller angle first.
This also adds a check to that function to swap the values around should that not be the case
2018-08-10 17:26:42 +02:00
asarium 66f95312ae Terminate FRED/qtFRED when command line demands it
This was reported by ngld who experienced issues with Knossos since FRED
did not terminate properly when asked to provide the command line flags.
This should fix that.
2018-08-01 09:20:18 +02:00
asarium a737c7a373 Update prebuilt FFmpeg libraries to version 3.4.4
This should fix an issue with the playback speed of APNG files which is
present in the current builds. This does not include the Mac libraries
since I cannot compile the libraries for that platform.
2018-07-31 15:43:52 +02:00
asarium ead93f3175 Add C++ operators for vector math operations
This makes it a bit easier to use the vector types since they are now
usable with the standard C++ operators.
2018-07-30 23:38:51 +02:00
asarium 48b1e3f289 Add support for looping movies
This adds a playback property for making the movie loop to the start
when the end is reached. The way this is done is by simply keeping the
decoder running even if the end of the movie is reached. Then the movie
is reset to the beginning and decoding continues. The player detects
this reset by examining the frame times which keeps the playback
constant.

This also includes support for this in the movie scripting API.
2018-07-30 18:10:48 +02:00
Fabian Woltermann 8a2641181f Merge pull request #1816 from asarium/fix/1815
Don't reset mission file name on mission end
2018-07-28 18:47:17 +02:00
m!m 36e8c3b623 Merge pull request #1814 from TRBlount/fix/random_cone
Fix vm_vec_random_cone/sphere functions
2018-07-28 18:44:58 +02:00
TRBlount 1c2a136ef7 Fix vm_vec_random_cone/sphere functions 2018-07-28 09:11:59 -06:00
asarium 72272cb8cf Don't reset mission file name on mission end
This was needed by the restart dialog action and got removed since the
Discord changes needed to know if a mission was active or not.

I removed the code which changed the mission file name and replaced it
with some internal handling in the discord code which should now handle
mission restarts better.

This fixes #1815.
2018-07-28 16:12:26 +02:00
m!m 4062f59128 Merge pull request #1813 from asarium/fix/stupidIfTypos
Fix crash when launching FSO without a mod option
2018-07-28 09:38:29 +02:00
asarium 24ab091671 Fix crash when launching FSO without a mod option 2018-07-27 18:17:18 +02:00
Fabian Woltermann 7cd17205b5 Merge pull request #1785 from asarium/feature/soundHandleIds
Use strongly typed handles for sound handles
2018-07-27 15:04:02 +02:00
Fabian Woltermann d58bd7db69 Merge pull request #1811 from asarium/fix/1754
Properly handle invalid UTF-8 sequences in NanoVG
2018-07-26 08:22:37 +02:00
m!m ce11936e56 Merge pull request #1810 from asarium/fix/discordLinkingIssue
Fix MSVC linking issue in new Discord Code
2018-07-25 23:18:00 +02:00
asarium feda97c148 Properly handle invalid UTF-8 sequences in NanoVG
The original issue was reported by Novachen in #1754 where a significant
slowdown was encountered in the controls menu (Ship and Misc tabs). I
traced the cause of the slowdown to repeated uploads of the NanoVG font
atlas texture even though no changes were necessary.

The root cause of the issue was that NanoVG did not handle invalid UTF-8
sequences at the end of a string properly. The UTF-8 decoder returned a
success code even though no code point was decoded which lead the rest
of the code to believe that the font atlas needed to be recreated.

This fixes #1754 by properly handling that case.

This also fixed an assertion failure if NanoVG was asked to render
2D elements without any vertices.
2018-07-25 14:17:06 +02:00
asarium a0e85e7ef5 Fix MSVC linking issue in new Discord Code
The CMake file did not contain the required target_link_libraries which
made the build fail when compiling it for the FastDebug configuration.
2018-07-25 13:31:33 +02:00
m!m 6939403262 Merge pull request #1808 from plieblang/MissionInfoParsing
Improve parsing of mission info text fields
2018-07-25 09:02:24 +02:00
Fabian Woltermann 33e8703555 Merge pull request #1788 from asarium/feature/discord
Add discord Rich Presence support
2018-07-25 08:21:23 +02:00
Fabian Woltermann 8a87d20415 Merge pull request #1801 from asarium/feature/shaderCacheLocation
Add CFile API for specifying the file location
2018-07-25 08:20:16 +02:00
Fabian Woltermann b324d2892c Merge pull request #1809 from EatThePath/master
Corrected faulty lifetime randomization for weapons in weapons.cpp
2018-07-25 08:16:46 +02:00
David Gibson 54bd7e3963 Corrected faulty lifetime randomization for weapons in weapons.cpp 2018-07-24 19:38:44 -05:00
plieblang b2230f723b Undo reformatting 2018-07-24 11:59:13 -07:00
m!m f75dafde4a Merge pull request #1746 from asarium/feature/objectDisplayString
Add ship display name feature
2018-07-24 15:49:11 +02:00
m!m d70f92e782 Merge pull request #1807 from asarium/fix/luaCallbackCrash
Fix crash on game shutdown if Lua object callbacks are used
2018-07-24 09:02:59 +02:00
plieblang d7e042b38a Dumb copy/paste mistake 2018-07-23 17:52:37 -07:00
plieblang 941a0c3c8a PR feedback and make methods static 2018-07-23 17:47:42 -07:00
plieblang edc6b94f7f Namespace resolution and size_type vs int mismatch 2018-07-23 13:38:34 -07:00
plieblang 1182a485ac Strip quotes from text and improve mission notes handling 2018-07-23 12:18:07 -07:00
asarium 3cd2c40331 Clear objects on game close 2018-07-23 19:21:16 +02:00
asarium c13cb44df4 Add ship display name feature
This adds a mission file option for ships which allows specifying a
different string which should be used for displaying the name of the
ship to the user. This name will not be used in SEXPs or other ship
lookup functions so it can be freely translated and two ships can also
have the same display name.

The new feature can be used by adding $Display name: <string> after $Name
for a ship in a mission file. I think I added proper support for FRED
(and qtFRED) so that this new value is properly saved but it would be
great if someone could test that.

This implements one of the features requested in #1730.
2018-07-22 23:16:00 +02:00
m!m aede65107b Merge pull request #1805 from asarium/feature/scriptingParsingApi
Add scripting API for accessing parsing system
2018-07-22 22:15:48 +02:00
asarium 197767ce94 Fix clang-tidy warnings 2018-07-22 11:47:33 +02:00
asarium 7924c66d37 Add function for listing files from CFile
This is basically a wrapper around cf_get_file_list which returns the
results in a table.
2018-07-22 11:47:33 +02:00
asarium 3106191cea Rename Mission_text to something better
The variable is now used by a lot of other things so it makes sense to
rename it to something that better describes what it is used for.
2018-07-22 11:47:33 +02:00
asarium 8c4ec9b91c Add scripting API for accessing parsing system
This allows scripts to use the same parsing functions which are also
used by the engine for parsing tables.
2018-07-22 11:47:33 +02:00
m!m 5bfcd1d063 Merge pull request #1804 from PeterMitsis/aicode-api-updates
Unused parameter removal from aicode.cpp module
2018-07-20 14:11:40 +02:00
Peter Mitsis 923265988c Fix warnings found by clang_tidy.sh
Signed-off-by: Peter Mitsis <[email protected]>
2018-07-19 19:24:23 -04:00
Peter Mitsis c485ed8199 aicode: Update maybe_cheat_fire_synaptic() API
Removes an unused parameter from the routine's API.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-19 13:09:35 -04:00
m!m 4353d4d47f Merge pull request #1803 from plieblang/MissionNoteSemicolonCrash
Write newline after mission notes
2018-07-19 17:06:11 +02:00
plieblang da65a66932 Semicolon fix for qtFRED as well 2018-07-18 13:57:29 -07:00
plieblang 7df8313b8b Force newline after mission notes 2018-07-18 13:33:27 -07:00
Peter Mitsis 187affe004 aicode: Update cheat_fire_synaptic() API
1. Removes unused parameter
2. Applies 'static' keyword to the routine.

Together, these two changes should help the compiler generate
more efficient code.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 16:24:17 -04:00
Peter Mitsis f29cc2ef86 aicode: Update ai_ship_destroy() API
Removes unused parameters from the routine.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 16:24:17 -04:00
Peter Mitsis 97e15ca135 aicode: Update ai_ship_hit() API
Removes two unused parameters from ai_ship_hit(). Instances where this
routine are called are also updated.

This should result in slightly more efficient code.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 16:24:17 -04:00
Peter Mitsis 868418c100 aicode: Update big_ship_collide_recover_start() API
Removes the unused parameter from the routine. This has a small
ripple effect such that it results in an unused parameter in one
of the routines from which it is called.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 16:24:17 -04:00
Peter Mitsis e413b10ce1 aicode: Update ai_control_info_check() API
1. Removes unused parameter
2. Applies the 'static' keyword to the routine.

Together, these two changes should help the compiler generate slightly
more efficient code.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 16:24:17 -04:00
Peter Mitsis bdd740eabd aicode: Update ai_find_shockwave_ship() API
1. Removes unused parameter
2. Applies 'static' keyword to the routine

Together, these two changes should help the compiler generate slightly
more efficient code.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 16:24:17 -04:00
Peter Mitsis d24e3c9295 aicode: Update ai_find_shockwave_weapon() API
1. Removes an unused parameter.
2. Applies the 'static' keyword to the routine.
3. Applies the 'const' keyword to the remaining parameter.

Together these changes should help the compiler generate slightly more
efficient code.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 16:24:13 -04:00
Peter Mitsis 13be144495 aicode: Update ai_preprocess_ignore_objnum() API
Applies the 'static' keyword to the routine as it is only used in the
module in which it is defined.

Removes an unused parameter.

Together, these two changes should help the compiler generate slightly
more efficient code.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 15:27:35 -04:00
Peter Mitsis 8857c4561a aicode: Update gwlr_object_1() API
Adds the 'static' keyword and removes unused parameters.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 15:25:22 -04:00
Peter Mitsis af4a2555db aicode: Update get_behind_ship() API
Adds the 'static' keyword to the routine as it is only used in the
module in which it is defined.

Removes its  unused parameter (and updates location where it is called).

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 15:25:22 -04:00
Peter Mitsis ae2c4ef098 aicode: Update ai_chase_eb() API
Removes the unused parameter from the routine and adds the 'static'
keyword to the routine as it is only used in the module in which it
is defined.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 15:25:22 -04:00
Peter Mitsis 6e509868d2 aicode: Update ai_fire_secondary_weapon() API
Removes unused parameters from the routine.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 15:25:22 -04:00
Peter Mitsis d0bc3cf91d aicode: Update ai_select_primary_weapon_OLD() API
This routine is only used in the module in which it is defined, so the
'static' keyword has been applied to it.

One of its three parameters was unused, so it has been removed.

Finally, the 'const' keyword has been applied to appropriate arguments.

These changes should help the compiler generate slightly more efficient
code.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 15:25:22 -04:00
Peter Mitsis 10079c88cd aicode: Remove fds_aux()
The routine fds_aux() is not used anywhere.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 15:25:22 -04:00
Peter Mitsis 3aacb6cb42 aicode: Update ai_turn_towards_vector() API
The routine ai_turn_towards_vector() had an unused parameter (frametime)
and it has been removed.

Each of the instances where this routine is called have also been updated
to reflect the parameter removal. As this resulted in the routine
swarm_update_direction() suddenly having an unused parameter, that routine
and the places where it is called have also been updated (remove
unused parameter).

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-17 15:25:22 -04:00
asarium b434776d53 Fix clang-tidy issues 2018-07-17 17:20:55 +02:00
asarium 20925f23cc Use new cfile location feature for pilot files
This was previously hard-coded but it is now possible to solve this
using the new location API.
2018-07-17 17:20:55 +02:00
asarium 64a9e3d03a Use location API for specifying shader cache location
The files are now exclusively stored in the top level user directory to
make the shader cache not dependent on the current mod. This also adds
some code which removes all old shader cache files which may be stored
in the old (per-mod) location.
2018-07-17 17:20:55 +02:00
asarium fe01372f46 Add CFile API for specifying location
This adds the capability for specifying a bit field for certain API
functions which will limit where they search for files.
2018-07-17 17:20:55 +02:00
asarium 7134e22322 Convert cfile find_location functions to return structs
The amount of output parameters is becoming quite large which makes it
harder to add new input parameters. For that reason I converted the
existing output parameters to a struct which cleans up the function
signature a lot.
2018-07-17 17:20:55 +02:00
m!m fac618c7f0 Merge pull request #1800 from PeterMitsis/remove-unused-parameters
Remove unused parameters
2018-07-16 22:33:22 +02:00
Fabian Woltermann b333104f45 Merge pull request #1799 from NovachenFS2/strings-translation-fix
Strings.tbl translation adjustments AddOn
2018-07-16 22:28:25 +02:00
Jenna Trassa c0401c24e5 Ballistic Weapon Energy Gauge 2018-07-16 10:46:02 +02:00
asarium 2ded9aa35d Format changes with clang-format 2018-07-16 10:21:52 +02:00
asarium ad54f588bb Use strongly typed handles for sound handles
This is similar to the other changes I already posted. Here the sound
instance handles are converted to their own handle type which will make
it easier to use the sound API.
2018-07-16 10:21:52 +02:00
Peter Mitsis a64ebca805 aibig: Update ai_big_maybe_enter_strafe_mode() API
Removes the unused parameter from ai_big_maybe_enter_strafe_mode().
Each place where this routine is called has been corrected to reflect
the updated API.

The 'const' keyword has been applied to remaining parameters as
necessary.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-15 22:27:43 -04:00
Peter Mitsis 69781cec25 aibig: Update ai_big_strafe_maybe_attack_turret() API
Adds the 'const' keyword to the parameters in the routine
ai_big_strafe_maybe_attack_turret() as they are unchanged
by the routine.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-15 22:19:56 -04:00
Peter Mitsis 137457e570 aibig: Update ai_big_strafe_maybe_retreat() API
The routine ai_big_strafe_maybe_retreat() is only used in the module in
which it is defined. Consequently it now sports the 'static' keyword, and
no longer uses the 'extern' keyword in its forward declaration (which has
been moved to be colocated with other forward declarations).

Secondly, since it was only using one of its two parameters, the unused
parameter has been removed.

Thirdly, since its only remaining parameter is not modified by the routine,
the 'const' keyword has been applied to it.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-15 22:02:35 -04:00
Peter Mitsis b7f3ba3660 aibig: Remove routine ai_big_ship()
The routine ai_big_ship() is empty, and appears to have been since it
was initially added many years ago. Removing it helps eliminate some
unused code.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-15 21:44:49 -04:00
Peter Mitsis bf6cfe61d7 aibig: Update ai_big_maybe_fire_weapons() API
The routine ai_big_maybe_fire_weapons() is only used in the file in
which it is defined and is thus a good candidate for being declared
'static'.

Furthermore, as it was only using two of the five parameters, the
three unused parameters have been removed and all instances where the
routine is called have been updated.

Signed-off-by: Peter Mitsis <[email protected]>
2018-07-15 21:44:08 -04:00
m!m 990838051a Merge pull request #1137 from asarium/lua/defaultScripts2
Add a lua loader that uses the CFile system
2018-07-15 22:57:40 +02:00
m!m 597104c479 Merge pull request #1798 from asarium/fix/debrisObjectsAssert
Convert debris object count Assert to Error
2018-07-15 22:57:25 +02:00
asarium 2ee5d21a10 Add discord Rich Presence support
This uses the Discord Rich Presence API for improving the integration of
FSO into Discord. At the moment this includes state notifications for
being in the main hall, the command and mission briefing and in-mission.
When in-mission it also includes the elapsed time of the mission with
support for time compression.

The details part of the notification includes the campaign name and
mission name if possible.
2018-07-15 19:37:24 +02:00
asarium 8c1d3492eb Convert debris object count Assert to Error
This will make the error message clearer instead of just showing a
cryptic Assert message. This cannot be handled by a simple warning since
capping num_debris_objects to MAX_DEBRIS_OBJECTS would then cause issues
when reading the rest of the header.
2018-07-15 18:34:44 +02:00
asarium ba5fcb971a Format changes with clang-format 2018-07-15 18:10:40 +02:00
asarium 5359b12b4f Only run valgrind on debug builds
In release builds there are a lot of false-positives probably due to the
optimizations of the compiler.
2018-07-15 18:10:40 +02:00
asarium 0fb7345617 Fix clang-tidy issues in gtest
Some of those are fixed in the newest version from their git repository
but I don't want to do a full update just for that.

modernize-make-unique was disabled since clang-tidy apparently doesn't
respect the language setting and make_unique is only present in C++14.
2018-07-15 18:10:40 +02:00
asarium a34ca578ba Add a lua loader that uses the CFile system
This allows to use the built-in lua "require" function with our file
system. This will help organize complicated scripts and it will also
allow to use libraries which were designed for this system.

To enable this change, this includes a new mechanism which allows to
load scripts from the default file system so that the files don't need
to be included in every mod. The default files can be overridden by a
mod if a special mod-table option has been set, similar to how external
shaders are handled right now.
2018-07-15 18:10:40 +02:00
m!m 7f03ac31ae Merge pull request #1797 from asarium/fix/particleEffectHandles
Use type-safe handles for particle effects
2018-07-15 16:37:31 +02:00
Fabian Woltermann 25b396f6a0 Merge pull request #1795 from NovachenFS2/strings-translation
Strings.tbl translation adjustments
2018-07-15 15:35:21 +02:00
asarium c6e2f94d0b Use type-safe handles for particle effects
Nightmare discovered an off-by-one error when checking the validity of a
particle effect handle. Since the new ID system makes that much easier
and less error-prone I decided to go ahead and convert all handles to
an ID typedef which also fixes the reported bug.
2018-07-15 14:50:32 +02:00
Jenna Trassa 9de8d45f19 Review changes for barracks.cpp 2018-07-15 09:25:17 +02:00
m!m 7f5168e9d6 Merge pull request #1796 from asarium/fix/movieBufferOffset
Use byte offset into immediate buffer for movie rendering
2018-07-14 23:47:34 +02:00
Jenna Trassa 490c5d8357 Review Changes in the hud.cpp 2018-07-14 22:28:18 +02:00
Fabian Woltermann 011ca4bb85 Merge pull request #1772 from asarium/build/betterSourceGroupFunction
CMake: Unify how source files are added to CMake
2018-07-14 21:50:00 +02:00
Fabian Woltermann a4f499ce8c Merge pull request #1789 from asarium/fix/shipCleanupMode
Fix assert in ship_cleanup
2018-07-14 21:48:47 +02:00
asarium 5578588894 Use byte offset into immediate buffer for movie rendering
This was causing issues when using the new scripting API in JAD where
there were a lot of 2D operations which filled up the immediate mode
buffer. The reason was that GL_ARB_vertex_attrib_binding the relative
offset is limited and the movie code adds the immediate buffer offset to
the vertex layout which then hit the offset limit set by OpenGL.

This fixes that by using the normal byte offset method which is already
used by the render_primitives functions.
2018-07-14 20:57:29 +02:00
Jenna Trassa dbee42bdec strings.tbl translation adjustments
Previously untranslateable strings can now translated, because they got an unique ID in the strings.tbl.
2018-07-14 14:43:05 +02:00
Jenna Trassa 783e4b5ab2 strings.tbl translation adjustments
Another duplicate that now uses a unique ID.
2018-07-14 14:39:24 +02:00
Jenna Trassa cea27244dc strings.tbl translation adjustments
A duplicate string that had an unique ID even there was an ID for this string. This one uses the initial ID for this string.
2018-07-14 14:36:03 +02:00
Jenna Trassa 09084395a5 strings.tbl translation adjustments
This string, that is used for the Docking precedure of the Support ship was untranslateable before. Now there is a given ID for the strings.tbl
2018-07-14 14:34:26 +02:00
Jenna Trassa 886b14e595 strings.tbl translation adjustments
A previously untranslateable string got an unique ID, that is translateable through the strings.tbl
2018-07-14 14:32:10 +02:00
Jenna Trassa 2fca5fd965 strings.tbl translation adjustments
The strings that got no ID got one. Aswell the duplicate string uses the id that is already predefined.
2018-07-14 14:30:24 +02:00
Jenna Trassa 69cb4f0136 strings.tbl translation adjustments
The string is getting an ID from the strings.tbl that is translateable.
2018-07-14 14:27:56 +02:00
Jenna Trassa 76d36b1c5f strings.tbl translation adjustments
A fix so that the duplicate string is using the id for the first string.
2018-07-14 14:26:48 +02:00
Jenna Trassa bf37a36e89 strings.tbl translation adjustments 2018-07-14 14:18:52 +02:00
Fabian Woltermann 6750f0a4cc Merge pull request #1794 from asarium/feature/scriptingMovies
Add scripting API for displaying movie files
2018-07-14 09:14:15 +02:00
asarium 06a21a0f9b Add scripting API for displaying movie files
This adds an API for the scripting system which allows it to load and
display movie files using the standard movie player code which includes
multi-threaded frame decoding.
2018-07-13 21:54:41 +02:00
m!m 3d653bd770 Merge pull request #1793 from asarium/feature/rgbMovies
Add support for movies with RGB(A) pixel format
2018-07-13 21:50:12 +02:00
asarium db3d92732f Add support for movies with RGB(A) pixel format
This allows to directly display RGB(A) movies without transcoding them
to YUV first. This allows the movie player to support APNG files (which
are supported natively by FFmpeg) with an alpha channel and without
converting them to YUV first.
2018-07-13 19:28:53 +02:00
MageKing17 4fbc0d02fa Merge pull request #1792 from fjelliott/shockwaves-check-huge-supercap-flags
Shockwaves caused by weapons respect big ship flags while calculating damage
2018-07-12 20:25:40 -07:00
Frans Elliott c6f75e7d14 Moved SUPERCAP_DAMAGE_SCALE macro from weapons.cpp to weapon.h so it can be used in shiphit.cpp. 2018-07-12 19:56:44 -05:00
Frans Elliott 8f4d2a27db Added a mod_table option that can enable/disable whether weapon shockwaves will respect the huge and supercap ship flags. The option is disabled by default to mirror retail behavior. 2018-07-12 19:17:31 -05:00
Frans Elliott c4bb136d80 Shockwaves caused by weapons will no longer deal lethal damage to big ships if the weapon that caused the shockwave isn't flagged as being able to deal lethal damage to that ship. For example, helios warheads now cannot kill a Sathanas, and small missiles that cause shockwaves (such as the EMP Adv.) cannot be used to kill corvettes. 2018-07-12 18:17:28 -05:00
m!m ea2656e75f Merge pull request #1790 from MageKing17/bugfix/inverted-sound-validity-check
Fix inverted validity check in snd_time_remaining().
2018-07-11 17:27:38 +02:00
MageKing17 d70672d7bc Fix inverted validity check in snd_time_remaining().
Overlooked mistake from PR #1777.
2018-07-10 17:17:38 -07:00
m!m ccc727a148 Merge pull request #1631 from Karajorma/Feature/EternalVariables
Feature/eternal variables
2018-07-10 15:15:29 +02:00
asarium 87ac2ca6a3 CMake: Unify how source files are added to CMake
This unifies how our CMake system handles adding source files to the
project so that all subprojects use the same mechanism. This also makes
it easier to add a new source folder to the code project since you don't
need to editor three places at the same time anymore.
2018-07-10 15:13:18 +02:00
Karajorma e8bd6b3929 Looks like I missed one. 2018-07-10 18:07:42 +08:00
Karajorma 4e7756d29f Fix errors in clang-tidy 2018-07-10 17:02:47 +08:00
asarium fd96dd287d Fix assert in ship_cleanup
The Assert did no cover all possible input values which caused some
isues for me. This fixes that.
2018-07-10 10:58:31 +02:00
m!m dea5fd9f30 Merge pull request #1784 from MageKing17/bugfix/target-priority-parsing
Make parse_weapon_targeting_priorities() work when weapon missing.
2018-07-10 10:46:18 +02:00
MageKing17 5ebf48b9b0 Adjustment in response to feedback/CI warning.
Warning() replaced with error_display(0), and a line changed to get rid of a clang-tidy warning about repeated types.
2018-07-09 12:07:42 -07:00
MageKing17 2dc2c0643f Merge pull request #1786 from asarium/fix/luaShipClassesIndex
Fix bounds check and string->int conversion in lua ship classes API
2018-07-09 03:14:47 -07:00
asarium e761d8a8e9 Fix bounds check and string->int conversion in lua ship classes API
The bounds check was not correct for 1-based indices. I moved the
Lua->C++ index conversion before the bounds check so that it makes
more sense.
Also, atoi isn't a reliable way for converting a string to an integer.
2018-07-09 10:32:08 +02:00
MageKing17 36b97487c6 Merge pull request #1787 from asarium/fix/invalidCampaignFile
Don't make invalid data in campaign file fatal
2018-07-08 19:20:22 -07:00
asarium 367825b1e0 Don't make invalid data in campaign file fatal
The previous code simply set a boolean flag to indicate that the data is
"invalid" which failed the campaign loading operation. With these
changes, those entries will simply be skipped. That can happen if a mod
added or removed a ship or weapon class or if two campaigns share the
same campaign name.
2018-07-08 10:29:59 +02:00
MageKing17 8f5a364345 Make parse_weapon_targeting_priorities() work when weapon missing.
Previously, if parse_weapon_targeting_priorities() couldn't find a weapon matching the name, it wouldn't parse the "+Target Priority:" line, so it would cause a parsing error when the parser failed to find "$Name:" or "#End" there. Now, the "match not found" codepath still parses it so that no mismatch occurs. Also, I reordered the function so that the parsing wasn't happening in the middle of a loop through the list of weapon types, because it made me cringe.
2018-07-07 10:48:23 -07:00
Fabian Woltermann 07a15286b4 Merge pull request #1777 from asarium/feature/soundIds
Use strongly-typed handles for sound entries
2018-07-07 14:21:44 +02:00
m!m 8e4deb0454 Merge pull request #1783 from MageKing17/bugfix/scripting-createship-safety
Lua's createShip() function now checks for a valid ship class.
2018-07-07 10:50:35 +02:00
MageKing17 aed44067df Lua's createShip() function now checks for a valid ship class.
Ideally it wouldn't be an optional argument at all, but that would break backwards-compatibility, so instead it'll just return an invalid ship handle instead of calling ship_create() with a class of -1. In addition, the Assert from ship_create() meant to guard against invalid ship_type values is now an Assertion that actually says what the invalid value of ship_type was, to make future debugging easier.
2018-07-06 19:25:31 -07:00
MageKing17 83844222c4 Merge pull request #1780 from asarium/build/prebuiltRetry
Retry prebuilt library download if it fails
2018-07-06 10:14:14 -07:00
MageKing17 ba5233e33b Merge pull request #1782 from asarium/fix/removeQuitMissionPopupHack
Remove hack for On Frame scripting hook and quit mission popup
2018-07-06 10:13:58 -07:00
MageKing17 b0bb660eb2 Merge pull request #1781 from asarium/fix/luaBackgroundDoc
Fix inconsistency in Lua background API documenation
2018-07-06 10:13:15 -07:00
MageKing17 74f258a9b3 Merge pull request #1776 from The-E/cleanup/downgrade_null_vec3d
Downgrade null vec3d warning to a log print
2018-07-06 09:58:02 -07:00
asarium d7d3b8c8e2 Remove hack for On Frame scripting hook and quit mission popup
I added this hack a long time ago and it always bothered me why I didn't
come up with a better solution. This is the better solution which uses
the popup_active function for determining if gr_flip is called within a
popup.
2018-07-06 17:03:29 +02:00
asarium 90aeb3651c Fix inconsistency in Lua background API documenation
The Lua type for matrices is called orientation instead of matrix.
2018-07-06 16:06:25 +02:00
asarium 6ee7679dd6 Retry prebuilt library download if it fails
This has been a problem for nighty and release builds which should be
fixed by this.
2018-07-06 14:48:32 +02:00
Karajorma 5baae08bdf Fix the qtFRED output to match that from regular FRED 2018-07-06 11:10:08 +08:00
MageKing17 646fb64c2f Merge pull request #1778 from asarium/feature/scriptingCallbacks
Add more generic scripting callback system
2018-07-05 15:13:02 -07:00
MageKing17 7544f321d6 Merge pull request #1771 from asarium/feature/scriptingBackgroundSupport
Add scripting API for manipulating mission backgrounds
2018-07-05 15:12:50 -07:00
Karajorma b2ff79fb38 That variable was meant to have a better name. 2018-07-05 14:06:04 +08:00
Karajorma 94c1cf65b3 Let's try this again. 2018-07-05 12:34:39 +08:00
Karajorma 0ce2908ce6 Fix the issues from the review and also fix an issue with qtFred 2018-07-05 12:20:30 +08:00
Karajorma 32fbe572e4 Merge branch 'master' of https://github.com/scp-fs2open/fs2open.github.com into Feature/EternalVariables 2018-07-05 10:31:54 +08:00
Goober5000 fb0ff8f1d0 Merge pull request #1779 from MageKing17/bugfix/lua-ship-targetsubsystem
Stop accessing Ships[] array with an objnum.
2018-07-03 21:53:09 -04:00
MageKing17 2cef1d4aa1 Stop accessing Ships[] array with an objnum.
Lua's Ship.TargetSubsystem VIRTVAR, when set, would write to an attribute of the Ships[] array based on an objnum instead of a ship instance index. Since MAX_OBJECTS is drastically higher than MAX_SHIPS, then depending on how many objects happen to be in the mission, an out-of-bounds array access can be easily generated. This commit makes sure to use the objnum instead as an index to the Objects[] array, and then retrieve the ship instance from it.
2018-07-03 16:50:36 -07:00
asarium 9dfb8faea3 Use strongly-typed handles for sound entries
This converts the previous int handles to a strongly-typed wrapper
handle which will make the API more self-documenting and will ensure
that wrongly used handles are detected at compile time.

I already found a few mistakes with these changes which I also fixed
here.
2018-07-03 10:43:10 +02:00
asarium 9651e7dca6 Add more generic scripting callback system
The current scripting hook is pretty simple and straight forward but it
makes a couple of scripting applications harder to implement than
needed.

For example, a lot of scripts need to do some work every frame
for all or some objects. The script needs to manage an internal list of
all the objects that are affected by that list which includes removing
invalid objects to conserve resources. This effectively mirrors what the
engine already does and adds unnecessary overhead.

In these changes I added a generic event system which can be used by any
part of the code for providing callbacks when a specific event occurs.
As an example, I added hooks for the pre- and post-move events to the
object class which are called before and after physics are applied to an
object.

I integrated that feature into the scripting system so now a script can
simply register a function as a callback which will be called whenever
the target event is executed.
2018-07-02 22:56:45 +02:00
Fabian Woltermann 51557d3aa3 remove extra braces 2018-07-01 09:00:36 +02:00
Fabian Woltermann 521a9b9461 Downgrade the null vec3d in vec3d normalize warning to a log print 2018-07-01 08:59:27 +02:00
m!m 130057c64a Merge pull request #1773 from asarium/fix/variableDlgInvalidName
Validate variable name when adding new variable
2018-07-01 00:45:31 +02:00
asarium f63e18957b Add scripting API for manipulating mission background
This adds a scripting API which can be used for adding and removing
background from a mission similarly to the existing SEXPs but with full
support for floating point numbers.

This was requested by Axem on Discord.
2018-06-30 23:22:07 +02:00
m!m df0be20d22 Merge pull request #1774 from The-E/cleanup/remove_path_warning
Remove "not enough points in path" warning
2018-06-30 23:20:22 +02:00
Fabian Woltermann cee37e7a2f Change this warning to a log print. This is only an issue when it's an issue, and most of the time it's not 2018-06-30 21:35:04 +02:00
asarium 90e16ffed2 Validate variable name when adding new variable
This is present in the variable modification dialog but not in the
editor which is used for adding a variable. This also adds the
validation to the editor for adding a new variable.
2018-06-30 17:42:20 +02:00
Fabian Woltermann c2a52174ba Merge pull request #1760 from asarium/build/gcc8Fixes
Fix GCC8 and FFmpeg warnings
2018-06-30 07:22:22 +02:00
Fabian Woltermann e389f7669d Merge pull request #1768 from asarium/feature/alwaysCacheBitmaps
Enable cache bitmaps by default and remove option
2018-06-30 07:20:56 +02:00
Fabian Woltermann 20681f1550 Merge pull request #1769 from TRBlount/feature/RNGSub
Add $Failure Rate:
2018-06-30 07:20:20 +02:00
TRBlount be8ea029da Resolve feedback 2018-06-29 11:19:56 -06:00
asarium 3dbcebb56e Enable cache bitmaps by default and remove option
Caching bitmaps between missions is no longer a problem for modern
system and this will improve the default load times when playing more
than one mission.
2018-06-29 12:15:21 +02:00
TRBlount 37453ae229 Add Failure Rate 2018-06-28 10:38:37 -06:00
m!m 9d907c99fe Merge pull request #1767 from MageKing17/feature/actual-weapon-range
Add AI profile flag to allow primary weapons to consider range.
2018-06-28 11:08:27 +02:00
MageKing17 490ef52b85 Add AI profile flag to allow primary weapons to consider range.
By enabling the "$Use Actual Primary Range:" profile flag (which can also be set on a per-AI-class basis), the code to determine if the AI should fire its primary weapons will not only perform its current "range based on speed of weapon and target" calculation, but it will also compute the weapon's actual range and not fire if the target is outside of it.
2018-06-27 23:11:40 -07:00
MageKing17 cf1cc5e862 Merge pull request #1765 from MageKing17/bugfix/primary-nolink-out-of-ammo
Nolink ballistic primaries no longer disallow linking when depleted.
2018-06-27 19:56:31 -07:00
m!m fc0105141b Merge pull request #1766 from asarium/fix/deferredSpecStatic
Apply spec_* values to lights in deferred pass
2018-06-27 23:27:57 +02:00
asarium 9878b48dd3 Apply spec_* values to lights in deferred pass
This was not present previously which meant that the command line values
were simply ignored by the engine. This adds the scaling back in which
should restore the lighting behavior to the previous status.
2018-06-27 19:39:14 +02:00
Fabian Woltermann af99fee8fc Merge pull request #1762 from asarium/feature/shaderCachePurge
Purge old shader cache files from file system
2018-06-27 19:13:25 +02:00
MageKing17 1cc09d5b8b Merge pull request #1764 from asarium/fix/emptyGameSoundPitch
Make sure that sound pitch range is initialized properly
2018-06-27 09:39:55 -07:00
MageKing17 d5c5cc6eb3 Nolink ballistic primaries no longer disallow linking when depleted.
When a ship with three primary banks has a Nolink weapon in one bank, the other two banks are still allowed to link; if that Nolink weapon has a limited ammo supply, however, depleting that ammo supply would disallow primary linking even though the weapon never contributed to primary linking in the first place. This commit changes the logic to only care if the depleted weapon doesn't have the Nolink flag. The ideal solution is probably to change how primary linking works so that even if the weapon doesn't have the Nolink flag the remaining primaries can still link, but that would be much more involved.
2018-06-27 09:04:14 -07:00
asarium b5bb5097b9 Make sure that sound pitch range is initialized properly
If a sound did not receive a valid sound name then the parsing function
would exit early and not set the pitch range properly. This would cause
a divide by zero if the duration of the sound was queried.

This moves the initialization of the pitch range to the start of the
parsing functions which makes sure that the range is initialized even if
the function exits early.
2018-06-27 17:23:13 +02:00
asarium f87e5bf318 Fix new warnings reported by GCC8
This also enabled GCC8 in Travis CI so that no new warnings are
introduced in other commits.
2018-06-26 11:51:08 +02:00
asarium 48667f0cbd Fix FFmpeg deprecation warnings 2018-06-24 23:07:00 +02:00
asarium 66637ef5cb Purge old shader cache files from file system
This automatically removes old shader cache files from the mod directory
when FSO is started. Those old files are likely to not be used anymore
so this will reduce the amount of disk space FSO uses for the shader
cache.
2018-06-24 22:21:33 +02:00
MageKing17 3b2b58e2cc Merge pull request #1757 from asarium/opengl/betterShaderCache
Improve handling of the shader cache
2018-06-23 21:51:07 -07:00
asarium d5282ca697 Improve handling of the shader cache
This adds an identification of the OpenGL implementation to the shader
content hash to avoid issues when using the same FSO install with
multiple graphics drivers.

Also adds support for querying the supported binary formats and
gracefully handling missing support for the format of a stored shader.
This can be useful when downgrading the version of a graphics driver
since the older version may not support the binary format yet.
2018-06-23 23:19:13 +02:00
m!m 6a099d2adc Merge pull request #1761 from asarium/fix/tgaLocking
Fix loading of TGA files with unexpected bit depths
2018-06-23 17:42:14 +02:00
Fabian Woltermann 6aa1f4899f Merge pull request #1756 from asarium/fix/modelClippingFlicker
Discard submodels by generating clipped vertices
2018-06-23 11:19:53 +02:00
asarium 4ec7d21965 Fix loading of TGA files with unexpected bit depths
The TGA loading code pretends that it does pixel conversion but doesn't
actually do that. This changes ensures that this circumstance is
communicated to the caller of bm_lock which will allow that code to
handle the case properly.

This was reported by Bomb3rman on discord.
2018-06-23 10:24:17 +02:00
MageKing17 bd5a4c4348 Merge pull request #1759 from Goober5000/cap_waypoint_speed_documentation
clarify documentation in cap-waypoint-speed
2018-06-21 18:13:00 -07:00
Goober5000 9135a01b1d clarify documentation in cap-waypoint-speed
The cap-waypoint-speed sexp only works for speeds above 0; this PR changes the documentation to clarify that.  I also tweaked an if() block in ship_return_time_to_goal because it used a >=0 comparison whereas every other comparison used >0.  (This is only for consistency, because the >0 check is used before this point would be reached.)
2018-06-21 17:04:02 -04:00
Fabian Woltermann 032579923e Merge pull request #1755 from asarium/fix/fullLogPathInLog
Write full log path and add legacy mode reason to log file
2018-06-18 08:08:36 +02:00
asarium 8c1e753991 Add log output for legacy mode reason
This will make debugging config location issues easier since the log
will state which path os_is_legacy_mode took while determining the
legacy mode status.
2018-06-17 20:51:11 +02:00
asarium 6a4c74084e Discard submodels by generating clipped vertices
This removes the clipping plane submodel removal code and replaces it
with shader code that generates vertices outside the clipping volume if
a model should not be rendered. This even improved performance since
clipping no longer needs to be active for all model rendering
operations.

This should finally fix #1579.
2018-06-17 14:27:19 +02:00
asarium 3799ce7d2f Write full log path to log file
This should make it a bit easier to determine if FSO is using the new
config file or the old one from only a log file.
2018-06-17 12:56:42 +02:00
m!m 2e213d5c97 Merge pull request #1659 from The-E/fix/1653
Delete all objects on mission end (Fix for #1653)
2018-06-17 12:14:22 +02:00
m!m 0c17177a1e Merge pull request #1713 from asarium/qtfred2_/goalsDialog
Port goal editor dialog code to qtFRED
2018-06-17 12:14:04 +02:00
m!m 93ced64c6f Merge pull request #1725 from asarium/opengl/thickModelOutlines
Render hardpoint model outlines using geometry shaders
2018-06-17 12:13:44 +02:00
m!m 4020b7c594 Merge pull request #1723 from asarium/feature/intelligentLegacyMode
Enable legacy config mode if legacy config is newer
2018-06-17 12:03:40 +02:00
m!m 13b26fd59f Merge pull request #1735 from asarium/cleanup/2dCallDereferences
Remove unnecessary function pointer dereferences in gr API
2018-06-15 12:03:14 +02:00
Goober5000 15bda8c4ac Merge pull request #1748 from asarium/build/unreachable
Add macro for marking unreachable code
2018-06-11 00:31:15 -04:00
asarium 39ab45dc7c Add macro for marking unreachable code
This can be used for mark parts of the code which should be unreachable
in normal execution. In debug mode, if such a statement is reached an
Error dialog is shown which aborts the execution. In release mode the
macro is replaced with a compiler specific expression that lets the
compiler know that this part is unreachable which allows it to optimize
the code better.
2018-06-09 17:38:17 +02:00
Fabian Woltermann 16a19783ae Merge pull request #1744 from asarium/fix/openAlGetErrorError
Fix OpenAL errors when sound is disabled
2018-06-09 08:41:15 +02:00
Goober5000 b1bc4ef44f Merge pull request #1743 from asarium/fix/1739
Respect trailing white space in tstrings.tbl strings
2018-06-08 21:14:33 -04:00
Goober5000 08e664a93a Merge pull request #1749 from asarium/feature/movieSrtSubtitles
Add support for external subtitle files
2018-06-08 20:55:42 -04:00
asarium aeee05c8dd Add support for external subtitle files
This allows to use external subtile files (currently only SRT is
configured) for providing subtitles for movie files. This should be more
universal since it also supports container formats with no support for
subtitle streams.

To use this code the srt file needs to be named
"<movie name>-<language code>.srt" where the language code is the file
extension name specified in the localization table. For english the
"-..." part can be omitted.
2018-06-08 23:29:15 +02:00
asarium 1fb3a65a90 Fix function brace wrapping in clang-format config 2018-06-08 23:28:54 +02:00
Goober5000 d53dc195ee Merge pull request #1742 from asarium/fix/1741
Enable log output for qtFRED
2018-06-08 15:21:14 -04:00
m!m 5b8880daa7 Merge pull request #1737 from Goober5000/fix_issue_1601
Change Warning about missing 640x480 interface art to a log statement
2018-06-08 19:42:41 +02:00
Goober5000 b0fc9cb31a address code review 2018-06-07 22:18:10 -04:00
m!m 323354295f Merge pull request #1751 from plieblang/PsnetTypoFix
Fix rsequence being reset twice and ssequence not being reset at all
2018-06-07 23:24:38 +02:00
plieblang b1881a700d Fix copy/paste error when closing socket 2018-06-07 12:12:54 -07:00
asarium 357cd76252 Render hardpoint model outlines using geometry shaders
This adds support for rendering models using thick lines (that means
lines wider than 1 pixel) which is required by the hardpoint HUD gauge.
This feature was present before the switch to OpenGL code and had to be
removed since the core profile does not support rendering lines wider
than 1 pixel.

This uses a geometry shader for converting all the triangles from a
model to 3 quads along the triangle lines which are as thick as set by
the model renderer. Geometry shaders are quite slow if they generate a
lot of geometry (and this generates 4 times the usual amount of geometry
in the shader) so it's probably not a very fast rendering operation but
it is only needed once per frame so it shouldn't be too bad.

I also added support for the RenderDoc API since I needed that for
debugging and it might be useful in the future. It will only become
active if RenderDoc is actually attached to the process so in most cases
the new code will do nothing.
2018-06-07 16:44:41 +02:00
Fabian Woltermann 30e70db561 Merge pull request #1750 from asarium/build/clang-format-config
Add initial clang-format config file
2018-06-07 13:40:14 +02:00
Goober5000 2c106f8c4b Merge pull request #1747 from ngld/pr/convertSexpInt3
Converted all Int3() calls in sexp.cpp into Warnings, Errors and Asserts
2018-06-06 22:59:50 -04:00
asarium 73bfb7a97e Add initial clang-format config file
This is largely based on how the existing code is formatted and is in no
way enforced by CI or anything else. This is only so that we actually
have a clang format file in the VCS since it's very useful.
2018-06-06 23:04:08 +02:00
ngld 4bead819f9 Implemented requested changes from code review 2018-06-06 03:35:13 +02:00
Goober5000 268828f092 Merge pull request #1736 from asarium/fix/translationBugs
Implement various translation features requested by Novachen
2018-06-05 21:28:14 -04:00
ngld 1614384a6a Converted all Int3() calls in sexp.cpp into Warnings, Errors and Asserts. 2018-06-06 02:20:52 +02:00
asarium 29b6af84cc Fix OpenAL errors when sound is disabled
Since there is no OpenAL context if sound is disabled there were errors
when calling alGetError on a non-existant context. This fixes that by
aborting the sound API call when the sound system wasn't initialized.
2018-06-05 12:31:37 +02:00
asarium cafee143c4 Respect trailing white space in tstrings.tbl strings
The current code drops trailing white space which can cause issues if
the translated string is used in concatenations. The retail tstrings.tbl
has some entries with white space at the end but since those strings are
not used for concatenations (or else this issue would have been found
earlier) this change should not cause issues there.

This fixes #1739.
2018-06-05 11:17:00 +02:00
asarium 6e21c8a736 Enable log output for qtFRED
This fixes #1741.
2018-06-05 11:09:31 +02:00
asarium bb56958dfc Fix various issues in the medal_stuff class
The assignment operator and copy constructors could be replaced with
their default implementations. The destrutor was also not needed since
it only executed the same action the default constructor would have
done.
2018-06-04 11:56:45 +02:00
asarium 120750ebd2 Adress code review feedback 2018-06-04 11:56:45 +02:00
asarium 3430a1c438 Disable hard-coded "cluster bomb" hack
This disables the old hack code if the weapon class has an alternate
name which may have been translated. See #1730 for more information.
2018-06-04 11:56:45 +02:00
asarium 1dc2e848cd Add option for disabling built-in translations 2018-06-04 11:56:45 +02:00
asarium 305429bf8b Add alternative display name for medals
This will only be used in the GUI which will allow translating the name
without having to change missions which use the name of the medal in
SEXPs.
2018-06-04 11:56:44 +02:00
asarium ae149b6061 Add convencience function for retrieving weapon alt name
I also fixed a few issues where the internal char array was used as a
mutable string which changed the string after it was parsed which is not
good(TM).

This also replaces all user-facing occurences of usages of name to use
the new function so that the correct, possibly translated, name is displayed
to the user.
2018-06-04 11:56:44 +02:00
Goober5000 429858d02e fix GitHub issue #1601
This turns the Warning about missing 640 interface art into a log print.  This applies to all instances of 640/1024: loading screens, cbrief and briefing backgrounds, and ship/weapon selection backgrounds.
2018-06-02 17:39:38 -04:00
asarium 1448277c29 Enable legacy config mode if legacy config is newer
There were some reports that using a newer launcher together with an
outdated launcher was causing some issues since the new launcher would
write the new config file which would cause FSO to ignore the changes of
the old launcher since the new config file already exists.

This fixes that by adding a check for when the config locations were
last modified. On Linux and Mac it checks when the old config locations
were modified last while on Windows it checks the registry to determine
if there was a change after the new config file was created.
2018-06-02 12:09:21 +02:00
Fabian Woltermann b848823a2f Merge pull request #1670 from asarium/feature/bitmapBlocks
Add new bmpman slot management system
2018-06-02 12:08:22 +02:00
Fabian Woltermann 61c533559b Removes an assert in object.cpp that was commented out and sets the number of retail stars to 0 when resetting the background in the lab 2018-06-02 11:58:01 +02:00
Goober5000 04b0f5bb75 Merge pull request #1721 from asarium/fix/unicodeScramble
Fix scrambling unicode messages
2018-06-01 17:24:04 -04:00
Goober5000 fdbba84a5b Merge pull request #1733 from Goober5000/fix_issue_1708
fix issue #1708
2018-05-31 15:52:46 -04:00
asarium e92121bed4 Remove unnecessary function pointer dereferences in gr API
Multiple function pointer dereferences are valid in C but do not change
the result of the operation. The graphics API had some function
definitions which used multiple pointer dereferences while the rest of
the functions did not.

This changes all occurences of the double dereferences to normal GR_CALL
declarations to keep the style in the API definitions consistent.
2018-05-31 15:07:20 +02:00
asarium 079ad97987 Fix clang-tidy issues in Assertion macro 2018-05-30 10:00:42 +02:00
asarium 7ae276fe6a Fix scrambling unicode messages
The code did not account for unicode escape sequences when inserting
scrambling characters which distorted the text and fequently caused
invalid UTF-8 sequences to appear in the text. This fixes that by
using the text iterators already present in the game code. I needed to
rewrite the logic of this block a bit since the previous logic could not
be converted to the way we need to handle unicode sequences at the
moment.

This fixes #1720.
2018-05-30 10:00:42 +02:00
Goober5000 45ddc8ac44 Merge pull request #1729 from chief1983/lib/sdl208
lib/sdl208: Upgrade the included SDL libs to 2.0.8.
2018-05-29 18:57:48 -04:00
Goober5000 6fa422c5e7 fix issue #1708 2018-05-29 17:04:31 -04:00
Cliff Gordon 35c830062d lib/sdl208: Upgrade the included SDL libs to 2.0.8. 2018-05-29 08:39:28 -05:00
Goober5000 243a5bb473 Merge pull request #1702 from Goober5000/minor_sexp_subsystem_cleanup
minor sexp subsystem cleanup
2018-05-29 00:21:29 -04:00
asarium 09abbe1789 Add new bmpman slot management system
This changes how the bitmap slots are managed by the bmpman system.
Instead of allocating a fixed-size array when the game starts this will
manage multiple "blocks" of bitmap slots. When the engine runs out of
slots in the already allocated blocks it simply creates a new block and
allocates the new slot in that.

This removed the hard limit on how many bitmaps can be loaded at the
same time and should fix issues encountered by mods which use a lot of
bitmap slots (I'm looking at you Spoon).

This implements the idea described in #1503.
2018-05-28 09:51:15 +02:00
asarium ad52278a67 Fix clang-tidy issues in Assertion macro 2018-05-28 09:51:15 +02:00
m!m e0a9c88241 Merge pull request #1716 from asarium/build/clang-tidy-diff
Use clang-tidy-diff to only check changed lines
2018-05-27 18:00:25 +02:00
m!m f45dcfc09a Merge pull request #1732 from asarium/fix/appveyorQt
Fix Appveyor Qt build issue
2018-05-26 16:54:23 +02:00
asarium 2036ebd3a0 Fix Appveyor Qt build issue
Apparently, Appveyor has removed the Qt version 5.7 from their servers
which was used by FSO previously. I have updated the paths to use Qt
5.9.5 instead now but there is a problem with Visual Studio 2013 since
there is no 32-bit Qt version for that compiler installed in the
Appveyor system.

For that reason, I decided to use Visual Studio 2015 instead for the
32-bit builds which means that Visual Studio 2013 will not be tested by
Appveyor anymore. Since no one is using that compiler version anymore
that shouldn't be a big issue.

This should fix the CI issues seen on recent PRs and commits.
2018-05-26 14:05:30 +02:00
m!m 469270d4b6 Merge pull request #1701 from Goober5000/is_in_turret_fov
is-in-turret-fov sexp
2018-05-17 19:34:49 +02:00
m!m e59df5d83c Merge pull request #1726 from Goober5000/sexp_bitwise_tweak
make the set-bit and is-bit-set operators fail gracefully
2018-05-17 19:31:22 +02:00
Goober5000 880e03e5d1 requested changes from code review 2018-05-15 22:04:20 -04:00
Goober5000 c1196f8286 requested changes from code review 2018-05-15 21:56:39 -04:00
Goober5000 40cd9e4c07 make the set-bit and is-bit-set operators fail gracefully
These operators used to warn and return NAN if they were given a bit index out of range.  For FREDding convenience, out-of-range bit indexes are now a no-op.  This is particularly helpful in the situation where a FREDder needs to evaluate an extended bit array, one 32-bit chunk at a time, e.g.

0-31 bits: offset 0
32-63 bits: offset -32
64-95 bits: offset -64
96-127 bits: offset -96

Because the sexp system always evaluates every argument, three out of four branches were always evaluated with invalid bit indexes (negative or too large) even if the sexp logic only used one branch.  The new method silently bypasses this behavior.
2018-05-07 18:44:58 -04:00
MageKing17 a90e480b61 Merge pull request #1724 from asarium/fix/showShipViewerMode
Fix "show-ship" flag
2018-05-05 11:35:27 -07:00
asarium 142ae846f4 Fix "show-ship" flag
The viewer mode check seemed to be wrong but I am not entirely sure if I
fixed this correctly. The Viewer_mode variable is a big mess of bitflags
that are not very consistent in what they mean.
2018-05-05 12:25:44 +02:00
asarium 7a827dcb0e Enable all modernize tests by default
This will report the usage of old coding patterns in new code.
modernize-raw-string-literal is disabled since it doesn't work right
with strings with special escape sequences in them.
modernize-use-using is disabled since typedefs are more common in the
FSO code.
2018-05-04 10:03:22 +02:00
asarium 619cb607d0 Use clang-tidy-diff to only check changed lines
This will only check the lines that were changed by a commit or pull
request. This makes it possible to enable more clang-tidy checks without
having to fix all occurences of the warnings in the code base.

Please note that the changes do not work correctly with rebased branches
due to the way Travis CI supplies the commit range. Pull requests will
always be checked properly though.
2018-05-02 12:26:05 +02:00
m!m 56c34eee6d Merge pull request #1685 from asarium/build/clang-tidy-2
Enable and fix more clang-tidy warnings
2018-05-01 19:35:46 +02:00
Fabian Woltermann 379031534d Merge pull request #1718 from asarium/fix/1717
Fix fog rendering in forward renderer
2018-04-29 18:49:04 +02:00
asarium 64b08f51c0 Fix fog rendering in forward renderer
There were actually two bugs here that were fixed:
1. The model draw list code disabled the fog rendering when it thought
it was it deferred rendering mode but did not account for explicitly
disabling the deferred renderer.
2. The fog effect was applied to both the emissive color and the base
color simultaneously which caused visual errors when rendering fogged
objects using the deferred renderer.

This fixes #1717.
2018-04-28 13:53:09 +02:00
asarium adfa12a706 Disable clang-tidy in release mode
The unused parameter warning cannot be disabled easily in release mode
for clang-tidy so this needs to be done to avoid false-positived in
release mode.
2018-04-25 11:57:56 +02:00
asarium d71a589b0f Use CMake 3.8 to make sure clang-tidy warnings fail the build
Previous versions do not support failing the build if warnings should be
treated as errors.
2018-04-25 11:57:56 +02:00
asarium 5118d94d5d Update header filter regex in .clang-tidy 2018-04-25 11:57:56 +02:00
asarium 17179d5b0b Fix unreferenced local variable warning 2018-04-25 11:57:55 +02:00
asarium bd3632d1bf Enable remaining misc- checks and fix detected issues 2018-04-25 11:57:55 +02: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 48873185ce Another batch of misc- checks 2018-04-25 11:13:20 +02:00
asarium e28ebc2a6c Enable and fix misc-suspicious-string-compare check 2018-04-25 11:13:19 +02:00
asarium dcac9e7223 Enable more misc- checks 2018-04-25 11:12:41 +02:00
asarium 0b4ca71eba Enable modernize-deprecated-headers 2018-04-25 11:12:41 +02:00
asarium 24c3c439d5 Test clang-tidy issues in test code 2018-04-25 11:12:41 +02:00
m!m 706973cb6b Merge pull request #1672 from asarium/feature/typesafeIDs
Add typesafe handle types and use it in game sound system
2018-04-25 10:36:46 +02:00
Fabian Woltermann 91a5bfa74a Merge pull request #1707 from asarium/feature/persistentParticles
Improve handling of non-persistent particles
2018-04-25 10:14:39 +02:00
asarium 7e399681cd Enable qtFRED for all deployments
This enabled qtFRED building for all deployments (releases, nightlies
and test builds). qtFRED is relatively stable now and should be
available for wider testing which may be provided by nightly builds.

This also adds AppImage support fot qtFRED although I still couldn't get
it to work entirely since there is some sort of libpng issue which
prevents icons from showing up correctly.
2018-04-24 14:57:52 +02:00
asarium f7b0f93c00 Port goal editor dialog code to qtFRED
The sexp_tree widget makes the model based dialog a bit ugly here since
it is required for some model operations even though it is a UI
component. In the future it could be split into a model component and an
UI component to allow better separation between model and UI.
2018-04-22 21:43:01 +02:00
m!m 2721c452c4 Merge pull request #1680 from asarium/qtfred2_/eventDialog
Port event editor dialog code to qtFRED
2018-04-22 21:39:57 +02:00
m!m 1030e29ef7 Merge pull request #1703 from asarium/qtfred2_/missionSave
Port mission save code to qtFRED
2018-04-22 17:40:48 +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 d1a6b48beb Improve handling of non-persistent particles
The current particle system uses dynamic allocation of particle
instances for keeping track of particle instances. This adds unnecessary
overhead in case the code does not need a handle to this particle which
is the case in pretty much all instances.

The new non-persistent particles are stored in a standard vector without
dynamic allocation which should make the processing steps using this
vector much faster and allow better scalability in case more particles
are used by a mission.
2018-04-22 16:22:28 +02:00
asarium ce8fc0a373 Try to close the window on Esc key presses
This will allow the user to cancel the operation or save their changes
instead of discarding them without question.
2018-04-22 16:21:55 +02:00
asarium 991f131376 Fix Clang warnings 2018-04-22 16:21:55 +02:00
asarium ed7917cb26 Port event handling part of Event editor code 2018-04-22 16:21:55 +02:00
asarium e6e6288423 Replace interface functions with qt signals 2018-04-22 16:21:55 +02:00
asarium 48a6361586 Port message handling code of event editor dialog 2018-04-22 16:21:55 +02:00
asarium 8a2faa8b99 Port mission save code to qtFRED
This is pretty much an exact copy of the mission save code of FRED2. I
removed the campaign save code for now since it requires some
interactions with the campaign editor which does not exist yet.
2018-04-22 16:21:41 +02:00
m!m 7d139f9e80 Merge pull request #1667 from asarium/build/teaci
Add TeaCI config file and fix MinGW warnings
2018-04-22 11:23:18 +02:00
m!m cf93aa43c5 Merge pull request #1709 from jg18/qtfred2_/shieldSystemDialog
Finish shield system editor dialog in qtFRED
2018-04-21 23:24:08 +02:00
asarium 89e3533106 Add TeaCI config file
TeaCI is a CI service which provides MinGW CI builds (in Docker
containers so no "real" Windows machines). This would be useful for
validating the Windows only code with additional GCC warnings. It would
also make sure that the MinGW setup we currently have continues to work.
2018-04-21 23:01:19 +02:00
m!m a3f9febdc4 Merge pull request #1668 from asarium/build/minGWFixes
Fix various issues detected by MinGW
2018-04-21 22:59:54 +02:00
jg18 3c738312de make corrections to shield system dialog based on feedback 2018-04-21 12:52:01 -07:00
jg18 363d6d3ba0 finish shield system editor dialog in qtFRED 2018-04-21 12:52:01 -07:00
niffiwan 5578825bf3 Merge pull request #1662 from asarium/fix/luaWaypointAPI
Fix Assert in Lua API when passing invalid name to mn.WaypointList
2018-04-21 23:31:51 +10:00
asarium 9b5710e8c3 Fix various issues detected by MinGW
This fixes various issues I found while trying to compile FSO in a cross
compilation setup using MinGW. This is a prerequisite for merging Tea-CI
support.
2018-04-21 15:13:25 +02:00
m!m b527dd5449 Merge pull request #1665 from asarium/fix/1664
Validate number of parsed briefing stages and icons
2018-04-21 12:47:26 +02:00
m!m 175668e2bb Merge pull request #1700 from asarium/qtfred2_/fixWindowsError
Fix Windows deployment issue
2018-04-21 12:45:55 +02:00
m!m cbf3052094 Merge pull request #1673 from asarium/build/ciFRED
Reenable FRED building for Appveyor
2018-04-21 12:45:34 +02:00
m!m 3507cf96d1 Merge pull request #1711 from asarium/fix/fredStaticInitializer
Fix crash on FRED startup in debug mode
2018-04-20 21:05:10 +02:00
asarium e624f6c1a8 Fix crash on FRED startup in debug mode
The crash was caused by a static initialization order problem where the
static initializer of the FRED app was called before the initializer of
the outwnd filter vector.

This fixes that by initializing the vector as soon as necessary through
the use of a function with a static variable.
2018-04-20 19:52:57 +02:00
asarium 371aad8f8c Fix warnings in FRED code 2018-04-20 14:46:21 +02:00
asarium cb3fd31db4 Reenable FRED building for Appveyor
Apparently this was also disabled accidentally when qtFRED was merged
into master.
2018-04-20 14:46:21 +02:00
niffiwan e2e7eac0c6 Merge pull request #1705 from asarium/qtfred2_/updatedReadme
Update qtFRED readme and add some documentation
2018-04-18 20:46:01 +10:00
asarium 80faaf88b0 Update qtFRED readme and add some documentation
This fixes #1696.
2018-04-18 11:41:29 +02:00
Goober5000 fb0f7dd7de minor sexp subsystem cleanup
Synchronize the two subsystem-of-ship checks in sexp.cpp and sexp_tree.cpp.  Mostly this is just adding OP_BEAM_FLOATING_FIRE to sexp_tree.cpp because whoever added that sexp forgot to add it there.
2018-04-15 18:49:37 -04:00
Goober5000 62aae9d793 add optional argument for distance/range 2018-04-15 18:24:58 -04:00
Goober5000 15663a3551 add is-in-turret-fov sexp
Returns true if the ship is in a turret's FOV, false otherwise.  Requested by JSRNerdo.  Uses the object_in_turret_fov internal function which is the same one used by the turret code when it checks whether it can fire.
2018-04-15 17:59:04 -04:00
m!m 6df837e7f3 Merge pull request #1686 from PeterMitsis/experiment
Minor clean up
2018-04-15 23:06:38 +02:00
asarium 512d08e443 Fix Windows deployment issue
The CMake code did not specify that qwindows.cll also needed to be
distributed with the application which caused errors for users who had
not installed Qt on their system.

This should make qtFRED redistributable without needing a QT
installation.
2018-04-15 19:35:06 +02:00
Peter Mitsis 504abeb305 ship: Remove unused routine ship_select_next_valid_secondary_bank()
Signed-off-by: Peter Mitsis <[email protected]>
2018-04-15 12:58:05 -04:00
Peter Mitsis 2ae2f2910c asteroid: Remove unused routine hud_target_asteroid()
Signed-off-by: Peter Mitsis <[email protected]>
2018-04-15 10:51:50 -04:00
Peter Mitsis 3b4fbde8e6 collide: Apply static keyword to applicable routines
Applying the 'static' keyword to applicable routines both informs the
developer where the routine is likely to be used as well as allows the
compiler to perform additional optimizations.

Signed-off-by: Peter Mitsis <[email protected]>
2018-04-14 19:57:04 -04:00
Peter Mitsis 2d01cd2366 shiphit: apply static keyword to applicable routines
Applies the 'static' keyword to applicable routines to both make it
more clear to the developer where such routines are likely to be used
as well as to provide additional information to the compiler so it can
make better optimizations.

Signed-off-by: Peter Mitsis <[email protected]>
2018-04-14 19:57:04 -04:00
Peter Mitsis 2beb136ecf shipfx: Apply static keyword to applicable routines
Applying the static keyword to applicable routines makes it both
more clear to the developer where those routines are likely to be
used as well as provide additional information to the compiler to
allow it to make better optimization choices.

Signed-off-by: Peter Mitsis <[email protected]>
2018-04-14 19:57:04 -04:00
Peter Mitsis c728cc40b2 ship: Apply static keyword to ship routines
Applies the 'static' keyword to various sihp related routines. This both
makes it more clear to the developer where those routines might be used
as well as allowing the compiler to leverage that knowledge and potentially
make additional optimizations.

Signed-off-by: Peter Mitsis <[email protected]>
2018-04-14 19:57:04 -04:00
Peter Mitsis d13ddb387f asteroid: Remove unused routines
Removes the following two routines as not only are they unused, but
they have been unused for years.
    get_debris_from_same_group()
    asteroid_get_random_in_cone()

Signed-off-by: Peter Mitsis <[email protected]>
2018-04-14 19:57:03 -04:00
Peter Mitsis 666c177dec Fix asteriod typo
Replaces instances of 'asteriod' with 'asteroid'.

Signed-off-by: Peter Mitsis <[email protected]>
2018-04-14 19:57:03 -04:00
Peter Mitsis d5ba2369a2 asteroid: Apply static keyword to asteroid routines
Applies the 'static' keyword to various asteroid routines. This both
makes it more clear to the developer where those routines might be used
as well as allowing the compiler to leverage that knowledge and potentially
make additional optimizations.

Signed-off-by: Peter Mitsis <[email protected]>
2018-04-14 19:57:03 -04:00
Peter Mitsis 7bf7a8fc66 keycontrol: Remove reference to hud_target_asteroid()
Removes the extern declaration of hud_target_asteroid() from
keycontrol.cpp as it is not used in that module.

Signed-off-by: Peter Mitsis <[email protected]>
2018-04-14 19:57:03 -04:00
asarium 5258066545 Validate number of parsed briefing stages and icons
This fixes two possible assertions and two possible buffer overflows
which could have been caused by a mission with wrong values for
$num_stages and $num_icons.

This fixes #1664.
2018-03-18 15:50:10 +01:00
asarium 55c1c3ce9d Fix wrong handle return type 2018-03-16 23:53:34 +01:00
asarium 2bddcf8344 Fix Assert in Lua API when passing invalid name to mn.WaypointLists
Since atoi return 0 on error the code tries to access the waypoint list
with index -1 which causes an assert in the lookup code. This fixes that
by using the error detection capabilities of strtol.
2018-03-16 23:53:19 +01:00
Fabian Woltermann 758ca86f6f And fix the other one too 2018-03-16 20:10:21 +01:00
Fabian Woltermann 6406e2fbd4 fix variable conversion warning 2018-03-16 15:53:19 +01:00
Fabian Woltermann 18c2dbbde9 WIP fix for #1653.
This adds a step to the post-mission cleanup where we explicitly go through Objects and call obj_delete on everything not already deleted; this obviously needs testing.

Also a few cleanup steps in lab_init to make sure the lab isn't contaminated by leftover data from previously played missions.
2018-03-16 12:59:43 +01:00
Karajorma ef6c5d4da7 Still have some old variable names 2018-03-01 20:09:34 +08:00
Karajorma cb960a3416 Fix the saving for non-eternal variables. 2018-03-01 19:26:41 +08:00
Karajorma 194d944108 Merge branch 'master' of https://github.com/scp-fs2open/fs2open.github.com into Feature/EternalVariables 2018-03-01 18:53:03 +08:00
Karajorma 9ac97f2422 Eternal Variables initial commit - Saving non-eternals on restart or mission quit not working properly. 2018-02-24 17:52:08 +08:00
z64555 ef0381d29f Extends the existing parse pausing system (used by bmpman) to use a bookmark stack. 2017-12-22 03:25:40 -06:00
1132 changed files with 194439 additions and 44242 deletions

No files matched your search

+182
View File
@@ -0,0 +1,182 @@
version: 2
references:
container_config: &container_config
docker:
- image: "debian:stretch"
working_directory: /root/build
restore_repo: &restore_repo
restore_cache:
keys:
- source-repo-{{ .Branch }}-{{ .Revision }}
- source-repo-{{ .Branch }}
- source-repo
cmake_configure: &cmake_configure
run:
name: Creating Build Files
command: |
mkdir build
cd build
CXXFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
CFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
if [[ "$CC" =~ ^clang.*$ ]]; then
CXXFLAGS="$CXXFLAGS -stdlib=libc++"
fi
eval $CC --version
export CXXFLAGS
export CFLAGS
CMAKE="cmake -G Ninja -DFSO_FATAL_WARNINGS=ON $CMAKE_OPTIONS"
eval $CMAKE -DCMAKE_BUILD_TYPE=$CONFIGURATION -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON ..
compile: &compile
run:
name: Compiling Source code
command: |
cd build
ninja -k 20 all
run_tests: &run_tests
run:
name: Run unit tests
command: |
./build/bin/unittests --gtest_shuffle
compile_steps: &compile_steps
steps:
- *restore_repo
- *cmake_configure
- *compile
- *run_tests
jobs:
checkout_code:
<<: *container_config
steps:
- run:
name: Installing Git
command: 'apt-get update && apt-get -yq install git'
- *restore_repo
- checkout
- run:
name: Updating submodules
command: 'git submodule update --init --recursive'
- save_cache:
key: source-repo-{{ .Branch }}-{{ .Revision }}
paths:
- .
build_gcc_lowest_debug:
docker:
- image: asarium/fso_compile:gcc-lowest
working_directory: /root/build
environment:
CC: gcc
CXX: g++
CONFIGURATION: Debug
<<: *compile_steps
build_gcc_lowest_release:
docker:
- image: asarium/fso_compile:gcc-lowest
working_directory: /root/build
environment:
CC: gcc
CXX: g++
CONFIGURATION: Release
<<: *compile_steps
build_gcc_latest_debug:
docker:
- image: asarium/fso_compile:gcc-latest
working_directory: /root/build
environment:
CC: gcc
CXX: g++
CONFIGURATION: Debug
<<: *compile_steps
build_gcc_latest_release:
docker:
- image: asarium/fso_compile:gcc-latest
working_directory: /root/build
environment:
CC: gcc
CXX: g++
CONFIGURATION: Release
<<: *compile_steps
build_clang_latest_debug:
docker:
- image: asarium/fso_compile:clang-latest
working_directory: /root/build
environment:
CC: clang-8
CXX: clang++-8
CONFIGURATION: Debug
<<: *compile_steps
build_clang_latest_release:
docker:
- image: asarium/fso_compile:clang-latest
working_directory: /root/build
environment:
CC: clang-8
CXX: clang++-8
CONFIGURATION: Release
<<: *compile_steps
build_clang_lowest_debug:
docker:
- image: asarium/fso_compile:clang-lowest
working_directory: /root/build
environment:
CC: clang
CXX: clang++
CONFIGURATION: Debug
<<: *compile_steps
build_clang_lowest_release:
docker:
- image: asarium/fso_compile:clang-lowest
working_directory: /root/build
environment:
CC: clang
CXX: clang++
CONFIGURATION: Release
<<: *compile_steps
workflows:
version: 2
build_test:
jobs:
- checkout_code
- build_gcc_lowest_debug:
requires:
- checkout_code
- build_gcc_lowest_release:
requires:
- checkout_code
- build_gcc_latest_debug:
requires:
- checkout_code
- build_gcc_latest_release:
requires:
- checkout_code
- build_clang_latest_debug:
requires:
- checkout_code
- build_clang_latest_release:
requires:
- checkout_code
- build_clang_lowest_debug:
requires:
- checkout_code
- build_clang_lowest_release:
requires:
- checkout_code
+103
View File
@@ -0,0 +1,103 @@
---
Language: Cpp
Standard: Cpp11
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowAllArgumentsOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^(<.*\.(h|hh|hpp)>)$' # Includes of external libraries
Priority: 5
- Regex: '^(<.*>)$' # standard library includes (won't match deprecated C headers)
Priority: 6
- Regex: '^"globalincs\/.*\.h"$' # globalincs always come first
Priority: 1
- Regex: '^"[^/]*\.(h)"$' # Local includes
Priority: 2
- Regex: '^".*\.(h)"$' # standard engine includes
Priority: 3
- Regex: '.*' # Catch all in case something is unhandled above
Priority: 4
IncludeIsMainRegex: '$'
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: ForContinuationAndIndentation
...
+28 -15
View File
@@ -1,27 +1,40 @@
---
Checks: "-*,\
modernize-use-override,\
modernize-*,\
-modernize-raw-string-literal,\
-modernize-use-using,\
-modernize-make-unique,\
-modernize-use-trailing-return-type,\
-modernize-avoid-c-arrays,\
performance-*,\
-performance-type-promotion-in-math-fn,\
misc-assert-side-effect,\
misc-bool-pointer-implicit-conversion,\
misc-definitions-in-headers,\
misc-fold-init-type,\
misc-forward-declaration-namespace,\
misc-inaccurate-erase,\
misc-inefficient-algorithm,\
misc-macro-repeated-side-effects,\
misc-misplaced-const,\
misc-move-forwarding-reference,\
misc-multiple-statement-macro,\
misc-new-delete-overloads,\
misc-noexcept-move-constructor,\
misc-*,\
-misc-macro-parentheses,\
-misc-misplaced-widening-cast,\
-misc-static-assert,\
-misc-unused-parameters,\
-misc-non-private-member-variables-in-classes,\
readability-*,\
-readability-function-size,\
-readability-identifier-naming,\
-readability-implicit-bool-conversion,\
-readability-inconsistent-declaration-parameter-name,\
-readability-isolate-declaration,\
-readability-magic-numbers,\
-readability-named-parameter,\
-readability-qualified-auto,\
-readability-uppercase-literal-suffix,\
-readability-else-after-return,\
"
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
HeaderFilterRegex: 'code/.*$|freespace2/.*$|qtfred/.*$|test/src/.*$|build/.*$'
AnalyzeTemporaryDtors: false
CheckOptions:
- key: 'misc-assert-side-effect.AssertMacros'
value: 'assert,Assert,Assertion'
- key: 'modernize-use-emplace.ContainersWithPushBack'
value: 'std::vector;std::deque;std::list;SCP_vector;SCP_deque;SCP_list'
- key: 'readability-braces-around-statements.ShortStatementLines'
value: '4' # Avoid flagging simple if (...) return false; statements
...
+2
View File
@@ -0,0 +1,2 @@
/build
/.git
+21
View File
@@ -0,0 +1,21 @@
build:
image: teaci/msys$$arch
pull: true
shell: mingw$$arch
commands:
- git submodule update --init --recursive
- if [ $$arch = 32 ]; then target=i686; fi
- if [ $$arch = 64 ]; then target=x86_64; fi
- pacman -S --needed --noconfirm --noprogressbar mingw-w64-${target}-pkg-config mingw-w64-${target}-cmake
- mkdir build && cd build
- cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=$$CONFIGURATION -DFSO_USE_SPEECH=OFF -DFSO_USE_VOICEREC=OFF -DFSO_FATAL_WARNINGS=ON -DFSO_BUILD_FRED2=OFF ..
- make -j$(nproc) all
matrix:
arch:
- 64
- 32
CONFIGURATION:
- Debug
- Release
+4
View File
@@ -5,3 +5,7 @@ indent_style = tab
[*.sdr]
indent_style = tab
[*.{yml,yaml}]
indent_style = space
indent_size = 2
+7
View File
@@ -0,0 +1,7 @@
# Default for everything
# * text=auto
# For the test data and built-in files to make them consistent on all platforms
*.tbl text eol=lf
*.tbm text eol=lf
*.sdr text eol=lf
+130
View File
@@ -0,0 +1,130 @@
name: Check a pull request
on: [pull_request]
jobs:
build_linux:
strategy:
matrix:
configuration: [Debug, Release]
compiler: [gcc-5, gcc-9, clang-4.0]
name: Linux
runs-on: ubuntu-16.04
steps:
- name: Prepare Environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:beineri/opt-qt571-xenial
sudo add-apt-repository ppa:msulikowski/valgrind # For fixing a bug with valgrind 3.11 which does not recognize the rdrand instruction
sudo apt-get -yq update
sudo apt-get -yq install cmake ninja-build libopenal-dev libreadline6-dev libpng12-dev libjpeg62-dev liblua5.1-0-dev libjansson-dev libsdl2-dev libfreetype6-dev valgrind qt57base g++-5 g++-9 clang-4.0 clang-tidy-4.0 libc++-dev libc++abi-dev
# Fix a header bug present in ubuntu...
sudo ln -s /usr/include/libcxxabi/__cxxabi_config.h /usr/include/c++/v1/__cxxabi_config.h
- uses: actions/checkout@v1
name: Checkout
with:
submodules: true
- name: Configure CMake
env:
CONFIGURATION: ${{ matrix.configuration }}
COMPILER: ${{ matrix.compiler }}
run: |
if [ "$COMPILER" = "gcc-5" ]; then
export CC=gcc-5
export CXX=g++-5
fi
if [ "$COMPILER" = "gcc-9" ]; then
export CC=gcc-9
export CXX=g++-9
fi
if [ "$COMPILER" = "clang-4.0" ]; then
export CC=clang-4.0
export CXX=clang++-4.0
fi
CXXFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
CFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
if [[ "$CC" =~ ^clang.*$ ]]; then
CXXFLAGS="$CXXFLAGS -stdlib=libc++"
fi
mkdir build
cd build
export CXXFLAGS
export CFLAGS
CMAKE="cmake -G Ninja -DFSO_FATAL_WARNINGS=ON $CMAKE_OPTIONS"
eval $CMAKE -DCMAKE_BUILD_TYPE=$CONFIGURATION -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON -DFSO_BUILD_QTFRED=ON ..
- name: Compile
working-directory: ./build
run: ninja -k 20 all
- name: Run Tests
working-directory: ./build
env:
CONFIGURATION: ${{ matrix.configuration }}
run: |
if [ "$CONFIGURATION" = "Debug" ]; then
valgrind --leak-check=full --error-exitcode=1 --gen-suppressions=all \
--suppressions="$GITHUB_WORKSPACE/ci/travis/valgrind.supp" ./bin/unittests --gtest_shuffle
else
./bin/unittests --gtest_shuffle
fi
build_windows:
strategy:
matrix:
configuration: [Debug, Release]
compiler: [MSVC]
arch: [Win32, x64]
name: Windows
runs-on: windows-2019
steps:
- name: Prepare Environment
run: choco install ninja
- uses: actions/checkout@v1
name: Checkout
with:
submodules: true
- name: Configure CMake
env:
CONFIGURATION: ${{ matrix.configuration }}
COMPILER: ${{ matrix.compiler }}
ARCHITECTURE: ${{ matrix.arch }}
shell: bash
run: |
mkdir build
cd build
if [ "$COMPILER" = "MinGW" ]; then
cmake -DFSO_USE_SPEECH="OFF" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
-DFSO_BUILD_FRED2="OFF" -DCMAKE_BUILD_TYPE=$CONFIGURATION -G "Ninja" ..
else
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
-DMSVC_SIMD_INSTRUCTIONS=SSE2 -DFSO_BUILD_FRED2="ON" -G "Visual Studio 16 2019" -T "v142" -A "$ARCHITECTURE" ..
fi
- name: Compile
working-directory: ./build
env:
CONFIGURATION: ${{ matrix.configuration }}
COMPILER: ${{ matrix.compiler }}
shell: bash
run: |
if [ "$COMPILER" = "MinGW" ]; then
cmake --build . --config "$CONFIGURATION"
else
cmake --build . --config "$CONFIGURATION" -- /verbosity:minimal
fi
- name: Run Tests
working-directory: ./build
env:
CONFIGURATION: ${{ matrix.configuration }}
COMPILER: ${{ matrix.compiler }}
shell: bash
run: |
if [ "$COMPILER" = "MinGW" ]; then
./bin/unittests --gtest_shuffle
else
"./bin/$CONFIGURATION/unittests" --gtest_shuffle
fi
@@ -0,0 +1,48 @@
name: Publish Standalone docker image
on:
push:
tags:
- '*'
jobs:
build_images:
strategy:
matrix:
configuration: [FastDebug, Release]
include:
- configuration: FastDebug
latest_tag: latest_debug
nightly_tag: nightly_debug
release_tag: release_debug
- configuration: Release
latest_tag: latest
nightly_tag: nightly
release_tag: release
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
name: Checkout
with:
submodules: true
- name: Docker login
run: echo ${{ secrets.DOCKER_ACCESSTOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Docker build
run: docker build --build-arg build_type=${{ matrix.configuration }} -f docker/standalone/Dockerfile -t ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.latest_tag }} .
- name: Push latest tag
run: |
docker push ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.latest_tag }}
- name: Push nightly tag
if: contains(github.ref, 'refs/tags/nightly_')
run: |
docker tag ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.latest_tag }} ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.nightly_tag }}
docker push ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.nightly_tag }}
- name: Push release tag
if: contains(github.ref, 'refs/tags/release_')
run: |
docker tag ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.latest_tag }} ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.release_tag }}
docker push ${{ secrets.DOCKER_REPOSITORY }}:${{ matrix.release_tag }}
+1 -3
View File
@@ -26,9 +26,6 @@
*.unsuccessfulbuild
ipch/
[Oo]bj/
[Bb]in
[Dd]ebug*/
[Rr]elease*/
Ankh.NoLoad
*.VC.db
*.VC.VC.opendb
@@ -260,3 +257,4 @@ CMakeSettings.json
# This gets ignored by one of the rules above for some reason...
!/code/scripting/lua/LuaConvert.h
!/code/debugconsole/
!/docker/build
+3
View File
@@ -1,3 +1,6 @@
[submodule "cmake/external/rpavlik-cmake-modules"]
path = cmake/external/rpavlik-cmake-modules
url = https://github.com/asarium/cmake-modules.git
[submodule "lib/libRocket"]
path = lib/libRocket
url = https://github.com/asarium/libRocket.git
+186 -140
View File
@@ -1,155 +1,201 @@
language: generic
language: bash
sudo: required
dist: trusty
dist: xenial
cache:
directories:
- $HOME/cmake-3.6
directories:
- $HOME/cmake-3.8
- $HOME/.ccache
- $HOME/curl_cache
addons:
apt:
packages: &global_deps
- ninja-build
- libopenal-dev
- libreadline6-dev
- libpng12-dev
- libjpeg62-dev
- liblua5.1-0-dev
- libjansson-dev
- libsdl2-dev
- valgrind
- qt57base
coverity_scan:
project:
name: "scp-fs2open/fs2open.github.com"
notification_email: [email protected]
build_command: "ci/travis/script.sh"
# must match TRAVIS_BRANCH check below
branch_pattern: coverity_scan
apt:
packages: &global_deps
- ninja-build
- libopenal-dev
- libreadline6-dev
- libpng12-dev
- libjpeg62-dev
- liblua5.1-0-dev
- libjansson-dev
- libsdl2-dev
- libfreetype6-dev
- qt57base
coverity_scan:
project:
name: "scp-fs2open/fs2open.github.com"
notification_email: [email protected]
build_command: "ci/travis/script.sh"
# must match TRAVIS_BRANCH check below
branch_pattern: coverity_scan
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
# also note that fork's don't get access to secure keys
# you have to test using a branch in the main repo
- secure: "C3wF967ZeliwwP1vC12EMIBOaC568n26Z/cPnwzn317ve59DWH3YSfPZVgvt08GzmaXITGGsJvPB+qxfGoKvQzYE4O1B73q81RpUe5pB3IhF+ThQ91VfQZIRJR5xEGJaLINUlHTTZGX5jxlkVO9wAcauVj/s3b8sQ3dvUZauPvk="
# These declarations set INDIEGAMES_USER and INDIEGAMES_PASSWORD for uploading nightly builds to the indiegames server
- secure: "lUuRu8XIi8MKNf1ebOfyC4iVEpPyASojJIDWXRo2bNqEF4ILAljXdkVeXeN6H5yKCHD52cxCNTtyePIG/o3p3QEuGSVud9bDS3D7LaQicLETGGrsw3l07U49gF2OKHXGopg0MzBbZUU9QmhoFTAe8t6PV9NDuEayYCheqvTqjZg="
- secure: "E/DHLYcPK/hBUqxBYYlUqp5sjgvIqY5A0qRHyQ4bmjsB+WB/Xx71bGCSiF7hk6lTxar1ZI1i5RAXXh9AIvNVaYAIdEOlCP+q3gvwCYuc5naZEKmkxlUCf0oEL4O9Fye93A/3VkFHuBdC1TGPYYf69m4W5r4367wWO9dPRIdWpJA="
# These declarations set FS2DOWNLOADS_USER and FS2DOWNLOADS_PASSWORD
- secure: "h6GbMX2jLsW1bS9fCM9fthOSJ1nfQQIRWi6EUH2p8u4NFLD5Bfi/C8JhQPKHUzyo3wvKkSHl+PsW7bgr1oXLusRwAur/dtv2N3imqvtbfIz305b00hZlsvbcYmQmUzQFSAdOGShK57JJ5aKQKccaUBP25KqB7Q+JaqBRdaMBS54="
- secure: "fUDAPAUUaaYZy8I4zU3SJ0JcK7aw4eb6eTdaEr7LyNyTMSfPgwY6P1MrbSQC0lJNQIUQ5ffjdxE5g7D7OYpoJF9L14ni4UY8t2QASt7kmpgcYihmjeuYy8FQXgmFG8CTxiWBPKTybZJ7voQcvIvRaNG7b2wM9PMfc5lRIondB6c="
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
# also note that fork's don't get access to secure keys
# you have to test using a branch in the main repo
- secure: "C3wF967ZeliwwP1vC12EMIBOaC568n26Z/cPnwzn317ve59DWH3YSfPZVgvt08GzmaXITGGsJvPB+qxfGoKvQzYE4O1B73q81RpUe5pB3IhF+ThQ91VfQZIRJR5xEGJaLINUlHTTZGX5jxlkVO9wAcauVj/s3b8sQ3dvUZauPvk="
# These declarations set INDIEGAMES_USER and INDIEGAMES_PASSWORD for uploading nightly builds to the indiegames server
- secure: "lUuRu8XIi8MKNf1ebOfyC4iVEpPyASojJIDWXRo2bNqEF4ILAljXdkVeXeN6H5yKCHD52cxCNTtyePIG/o3p3QEuGSVud9bDS3D7LaQicLETGGrsw3l07U49gF2OKHXGopg0MzBbZUU9QmhoFTAe8t6PV9NDuEayYCheqvTqjZg="
- secure: "E/DHLYcPK/hBUqxBYYlUqp5sjgvIqY5A0qRHyQ4bmjsB+WB/Xx71bGCSiF7hk6lTxar1ZI1i5RAXXh9AIvNVaYAIdEOlCP+q3gvwCYuc5naZEKmkxlUCf0oEL4O9Fye93A/3VkFHuBdC1TGPYYf69m4W5r4367wWO9dPRIdWpJA="
# These declarations set DATACORDER_USER and DATACORDER_PASSWORD
- secure: "dpBH/dDN3bmU/NFlh+2v9isNx9wX0ocoRy+W+kBXRH32sosUGp26REhMqgVRpBNP5oxPBU8ic5bEogxAYWCB+0xUygBbkxAwyMPgoA34s0OXdTCY/ofw14ni8qqV2Ffy7fQJbP/jkMURyiMHx3kBTxNv3YjxKJqLnOuOMlQLpT8="
- secure: "tLMRBD1Ufp5iKNwlqPDVbbuczgusaXNoBJyAnPATpJq2YwlkW4j3PqP9rW5vd85+52xam2EOP20w9PoBR5J6FLdiXRu4Lf7yCEhSHFAgowVqQj8QcJpPlyXr90bM4emFGrGqpdxVwxyQ5AFhKwLuEZKsI14GYLN+UMEwpNCMing="
deploy:
- provider: releases
api_key:
secure: "Wdt4Ccefo7a0ZDjEJQJgpghh7n72FtNJuKSAPUvoz4gtEX6Ct9J8yJI1t9V3jE3CTbbLJ21/Q6eZRDfT7UfNJe5DdepoJsP9DeFhKMWqQCq+AChqQWlm0KeZAffJoJreL8vXYhnRYcLT9ceZHEH6AqwN9TPV+xJziGPISAkYNZ8="
skip_cleanup: true
file_glob: true
file: "/tmp/builds/*"
on:
condition: '"$RELEASE_BUILD" == true'
tags: true
- provider: releases
api_key:
secure: "q619+eQTe7lv8UVphK4OIzU8Jw84KBbVkuprN2sWIubRcV3IbZr2+WahJoUMt+nyhiy3YjDYtstO2ZgkxupwnZgwGUBVIiD1c4SPuyy+HTjNMOtiVsEUHT2hf+xPAemWpTlK5HcwhMmHAOh6rt6dEj57QOg0gcmGiwD/tCbEriA="
skip_cleanup: true
file_glob: true
file: "/tmp/builds/*"
on:
condition: '"$RELEASE_BUILD" == true'
tags: true
- provider: script
script: bash ci/travis/ftp_deploy.sh
on:
condition: '"$NIGHTLY_BUILD" == true'
tags: true
- provider: script
script: bash ci/travis/ftp_deploy.sh
on:
condition: '"$NIGHTLY_BUILD" == true'
tags: true
- provider: script
skip_cleanup: true
script: bash ci/travis/ftp_deploy.sh
on:
condition: $TEST_BUILD = true
all_branches: true
- provider: script
skip_cleanup: true
script: bash ci/travis/ftp_deploy.sh
on:
condition: $TEST_BUILD = true
all_branches: true
matrix:
include:
# note that gcc Debug MUST be 1st for Coverity
- os: linux
env: CONFIGURATION="Debug" CC=gcc-5 CXX=g++-5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-trusty'
packages:
- *global_deps
- g++-5
- os: linux
env: CONFIGURATION="Debug" CC=gcc-7 CXX=g++-7
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-trusty'
packages:
- g++-7
- *global_deps
- os: linux
env: CONFIGURATION="Debug" CC=clang-4.0 CXX=clang++-4.0 CMAKE_OPTIONS="-DENABLE_CLANG_TIDY=ON -DCLANG_TIDY_EXE=/usr/bin/clang-tidy-4.0"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- sourceline: 'ppa:beineri/opt-qt571-trusty'
packages:
- *global_deps
- clang-4.0
- clang-tidy-4.0
- libc++-dev
- os: osx
env: CONFIGURATION="Debug"
include:
# note that gcc Debug MUST be 1st for Coverity
- os: linux
env: CONFIGURATION="Debug" CC=gcc-5 CXX=g++-5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- g++-5
- os: linux
env: CONFIGURATION="Debug" CC=gcc-9 CXX=g++-9
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- g++-9
- *global_deps
- os: linux
env: CONFIGURATION="Debug" CC=clang-4.0 CXX=clang++-4.0 CMAKE_OPTIONS="-DCLANG_USE_LIBCXX=ON"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- clang-4.0
- libc++-dev
- libc++abi-dev
- os: linux
env: CONFIGURATION="Debug" CC=clang-9 CXX=clang++-9 CMAKE_OPTIONS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- g++-9
script:
- ./ci/travis/script.sh
- ./ci/travis/clang_tidy.sh
- os: osx
env: CONFIGURATION="Debug"
- os: windows
env: CONFIGURATION="Debug" CMAKE_TOOLSET=v141_xp CMAKE_GENERATOR="Visual Studio 15 2017"
- os: windows
env: CONFIGURATION="Debug" CMAKE_TOOLSET="" CMAKE_GENERATOR="Ninja"
- os: linux
env: CONFIGURATION="Release" CC=gcc-5 CXX=g++-5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- g++-5
- os: linux
env: CONFIGURATION="Release" CC=gcc-9 CXX=g++-9
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- g++-9
- *global_deps
- os: linux
env: CONFIGURATION="Release" CC=clang-4.0 CXX=clang++-4.0 CMAKE_OPTIONS="-DCLANG_USE_LIBCXX=ON"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- clang-4.0
- libc++-dev
- libc++abi-dev
- os: linux
env: CONFIGURATION="Release" CC=clang-9 CXX=clang++-9 CMAKE_OPTIONS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-xenial'
packages:
- *global_deps
- g++-9
script:
- ./ci/travis/script.sh
- ./ci/travis/clang_tidy.sh
- os: osx
env: CONFIGURATION="Release"
- os: windows
env: CONFIGURATION="Release" CMAKE_TOOLSET=v141_xp CMAKE_GENERATOR="Visual Studio 15 2017"
- os: windows
env: CONFIGURATION="Release" CMAKE_TOOLSET="" CMAKE_GENERATOR="Ninja"
# There is a GCC compiler bug with MinGW that causes compilation failures on Windows at the moment
allow_failures:
- os: windows
env: CONFIGURATION="Debug" CMAKE_TOOLSET="" CMAKE_GENERATOR="Ninja"
- os: windows
env: CONFIGURATION="Release" CMAKE_TOOLSET="" CMAKE_GENERATOR="Ninja"
fast_finish: true
- os: linux
env: CONFIGURATION="Release" CC=gcc-5 CXX=g++-5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-trusty'
packages:
- *global_deps
- g++-5
- os: linux
env: CONFIGURATION="Release" CC=gcc-7 CXX=g++-7
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-trusty'
packages:
- g++-7
- *global_deps
- os: linux
env: CONFIGURATION="Release" CC=clang-4.0 CXX=clang++-4.0 CMAKE_OPTIONS="-DENABLE_CLANG_TIDY=ON -DCLANG_TIDY_EXE=/usr/bin/clang-tidy-4.0"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- sourceline: 'ppa:beineri/opt-qt571-trusty'
packages:
- *global_deps
- clang-4.0
- clang-tidy-4.0
- libc++-dev
- os: osx
env: CONFIGURATION="Release"
before_install:
# ugly hack; if running a coverity scan abort all except the 1st build
# see note re gcc compiler above needing to be 1st
# also note that branch_pattern & the TRAVIS_BRANCH check must match
# unfortunately COVERITY_SCAN_BRANCH isn't defined until later in the
# build process
- if ([[ "${TRAVIS_JOB_NUMBER##*.}" != "1" ]] && [[ "${TRAVIS_BRANCH}" == "coverity_scan" ]]); then false ; fi
- source "./ci/travis/check_release.sh"
- "./ci/travis/before_install.sh"
# ugly hack; if running a coverity scan abort all except the 1st build
# see note re gcc compiler above needing to be 1st
# also note that branch_pattern & the TRAVIS_BRANCH check must match
# unfortunately COVERITY_SCAN_BRANCH isn't defined until later in the
# build process
- if ([[ "${TRAVIS_JOB_NUMBER##*.}" != "1" ]] && [[ "${TRAVIS_BRANCH}" == "coverity_scan" ]]); then false ; fi
- source "./ci/travis/check_release.sh"
- "./ci/travis/before_install.sh"
install:
- "./ci/travis/install.sh"
- export PATH=$HOME/cmake-3.6/bin:$PATH
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export PATH="/c/Program Files/CMake/bin":$PATH; fi
- "./ci/travis/install.sh"
- export PATH=$HOME/cmake-3.6/bin:$PATH
before_script:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then QT_ENV_SCRIPT=$(find /opt -name 'qt*-env.sh'); source $QT_ENV_SCRIPT; fi
- "./ci/travis/before_script.sh"
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then QT_ENV_SCRIPT=$(find /opt -name 'qt*-env.sh'); source $QT_ENV_SCRIPT; fi
- "./ci/travis/before_script.sh"
script:
- if [ "$BUILD_DEPLOYMENT" = true ] ; then ./ci/travis/release.sh ; else ./ci/travis/script.sh ; fi
- if [ "$BUILD_DEPLOYMENT" = true ] ; then ./ci/travis/release.sh ; else ./ci/travis/script.sh ; fi
-29
View File
@@ -1,29 +0,0 @@
Original source (Freespace 2) by Volition, Inc.; see "credits.tbl"
Modifications by the FreeSpace Source Code Project (FSSCP)
http://fs2source.warpcore.org
FS2_OPEN STAFF:
Project leader:
Edward "Inquisitor" Gardner
Programmers:
"Bobboau"
Dennis "DTP" Pedersen
Ian "Goober5000" Warfield
Joe "Righteous1" Dowd
Mike "penguin" Harris
"Mysterial"
"PhReAk"
Thomas "Random Tiger" Whittaker
Will "Unknown PLayer" Rousnel
"WMCoolmon"
Web support:
Icefire and the staff at Volitionwatch.com
Alex "Thunder" Avery and the staff at Hard Light Productions
Special thanks to:
Volition for making FS2 such a great game
Dave Baranec for giving us the code and keeping us sanity checked
+41
View File
@@ -0,0 +1,41 @@
## FreeSpace
FreeSpace: The Great War (Released 1998) and FreeSpace 2 (1999) are mission-based space combat simulators, like X-Wing/TIE Fighter and Wing Commander. Among the greatest games of the genre, they were also effectively the last.
The FreeSpace series follows humanity and their Vasudan allies as they fight to withstand the xenocidal, enigmatic Shivans, a species of unknown origin, vast technological capability, and seemingly limitless malice.
## FreeSpace Open
Thanks to Volition's generosity, we've continued development of FreeSpace 2 as FreeSpace Open, building graphical enhancements to bring the original games up to modern standards, telling new stories set in the FreeSpace universe and original worlds, and creating spectacular total conversions that let players fly in the beloved universes of Babylon 5, Battlestar Galactica, Wing Commander, and Star Wars.
## Hard-Light Productions
HLP is a fan community built on love and open-source code. We're dedicated to bringing modders together and giving them a place to share their own hard work and draw inspiration from the work of others. Thanks to Volition's generosity, we've continued development of FreeSpace 2 as FreeSpace Open, building graphical enhancements to bring the original games up to modern standards, telling new stories set in the FreeSpace universe and original worlds, and creating spectacular total conversions that let players fly in the beloved universes of Babylon 5, Battlestar Galactica, Wing Commander, and Star Wars.
Find us at:
- Our [website](http://www.hard-light.net/) and [forums](http://www.hard-light.net/forums/)
- [Discord](https://discord.gg/YNVP3WR)
- [Facebook](https://www.facebook.com/groups/Hardlightproductions/)
- [Youtube](https://www.youtube.com/channel/UCxKkd609hDtY6yNetR1iT4w)
- [Reddit](https://www.reddit.com/r/freespace/)
- [Twitter](https://twitter.com/hardlightpro)
- [IRC](irc://irc.esper.net/hard-light)
## How to get the game
FreeSpace Open requires a retail installation of FreeSpace 2, which is available at the following stores:
- [GOG.com](https://www.gog.com/game/freespace_2)
- [Steam](https://store.steampowered.com/app/273620/Freespace_2/)
After installing retail FS2, use [Knossos](https://fsnebula.org/knossos/) to upgrade to the most recent release of FSO. Knossos is an advanced mod manager and launcher for FSO.
## Improvements
The new open source game engine has several distingushing features including:
- Linux and Mac OS X support
- OpenGL support
- OpenAL audio support
- Easy mod installation
- OGG support
- Hardware transform, clipping, and lighting
## The FreeSpace Upgrade Project
While the SCP improves the code of the game engine to enable new and exciting features, the FreeSpace Upgrade Project (FSU) creates material that takes advantage of the improved game engine.
The FSU improves the ships, effects, and background elements of FreeSpace 2. Every now and then these improvements are released as a pack called MediaVPs. These assorted improvements enhance the graphics of the game.
While the best way to experience the FSU is by playing the game with it, you can watch this [comparison video](https://www.youtube.com/watch?v=RM1YC_gK-qo) between 1999 and 2019 to have an idea of how much more beautiful FSU makes the game.
^(Much of this content was pulled from existing sources, such as InsaneBaron's "What Is Hard Light Productions" [thread](https://www.hard-light.net/forums/index.php?topic=86650.0), the Wiki's [Getting Started article](https://wiki.hard-light.net/index.php/Getting_started) and more.)
+8
View File
@@ -0,0 +1,8 @@
Original source (Freespace 2) by Volition, Inc.; see "`credits.tbl`"
Modifications by the FreeSpace 2 Source Code Project [(FSO SCP)](https://www.hard-light.net/forums/index.php?board=50.0)
[Project Contributors](https://github.com/scp-fs2open/fs2open.github.com/graphs/contributors)
Special thanks to:
Volition for making FS2 such a great game
Dave Baranec for giving us the code and keeping us sanity checked
+13 -2
View File
@@ -10,7 +10,7 @@ endif()
include(cmake/util.cmake)
# Set a few policies
set_policy(CMP0051 OLD)
set_policy(CMP0051 NEW)
set_policy(CMP0053 NEW)
set_policy(CMP0054 NEW)
@@ -84,7 +84,6 @@ IF (WIN32)
OPTION(FSO_BUILD_FRED2 "Build FRED2 binary" ON)
elseif(UNIX)
option(FSO_BUILD_APPIMAGE "Build an AppImage package" OFF)
set(APPIMAGE_ASSISTANT "" CACHE STRING "The root directory of an AppImage clone.")
ENDIF(WIN32)
OPTION(FSO_BUILD_TOOLS "Build tools related to FSO" OFF)
@@ -116,6 +115,12 @@ SET(FSO_RUN_ARGUMENTS "" CACHE STRING "Additional arguments passed to a generate
option(FSO_INSTALL_DEBUG_FILES "Install some debug files (currently only PDB files on windows)" OFF)
option(ENABLE_COTIRE "Enable cotire for faster compilation. Enabled by default." ON)
option(FSO_RELEASE_LOGGING "Enable logging output for release builds" OFF)
OPTION(FSO_BUILD_WITH_FFMPEG "Enable the usage of FFmpeg for sound and custscenes" ON)
MARK_AS_ADVANCED(FORCE FSO_CMAKE_DEBUG)
MARK_AS_ADVANCED(FORCE FSO_BUILD_INCLUDED_LIBS)
MARK_AS_ADVANCED(FORCE FSO_USE_OPENALSOFT)
@@ -123,6 +128,9 @@ MARK_AS_ADVANCED(FORCE FSO_USE_LUAJIT)
MARK_AS_ADVANCED(FORCE FSO_DEVELOPMENT_MODE)
MARK_AS_ADVANCED(FORCE FSO_FATAL_WARNINGS)
mark_as_advanced(FORCE FSO_INSTALL_DEBUG_FILES)
mark_as_advanced(FORCE ENABLE_COTIRE)
mark_as_advanced(FORCE FSO_RELEASE_LOGGING)
mark_as_advanced(FORCE FSO_BUILD_WITH_FFMPEG)
# Include cotire file from https://github.com/sakra/cotire/
include(cotire)
@@ -188,9 +196,12 @@ include(doxygen)
IF (WIN32)
message(STATUS "Using text to speech: ${FSO_USE_SPEECH}")
message(STATUS "Using voice recogition: ${FSO_USE_VOICEREC}")
message(STATUS "Building FRED2: ${FSO_BUILD_FRED2}")
elseif(UNIX)
message(STATUS "Building AppImage: ${FSO_BUILD_APPIMAGE}")
ENDIF()
message(STATUS "Building FSO tools: ${FSO_BUILD_TOOLS}")
message(STATUS "Building qtFRED: ${FSO_BUILD_QTFRED}")
message(STATUS "Fatal warnings: ${FSO_FATAL_WARNINGS}")
message(STATUS "Release logging: ${FSO_RELEASE_LOGGING}")
message(STATUS "With FFmpeg: ${FSO_BUILD_WITH_FFMPEG}")
+128 -19
View File
@@ -1,23 +1,131 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [19.0.0] - 2020-01-25 ([Thread](https://www.hard-light.net/forums/index.php?topic=96226.0))
### Meta
- With this release we decided to drop the "`3.Major_revision.Minor_revision`" versioning scheme in favor of a year based scheme since the Major and Minor versions did not have much meaning anymore. Instead the scheme will now be "`<year>.<number that is incremented every release>.0`". The last 0 is still there because some of our systems expect that. It will be gone at some point.
### Added
- Full Unicode text support: You can now use non-ASCII characters without having to worry about special fonts and special characters. This is an opt-in mod flag.
- Translation features for making it easier to only distribute one version of a mod which includes all languages.
- OpenAL Soft is included by default in binary distributions of FSO now.
- System for dynamically adding new SEXPs. With this a Lua script can expose functionality to the mission which can be used exactly the same as a standard SEXP with all the usual editing features in FRED.
- Support for displaying decals on the surface of an object.
- Integrated support for the [Discord Rich Presence API](https://discordapp.com/rich-presence).
- New markup based user interface system using [libRocket](https://github.com/libRocket/libRocket).
### Changed
- Exposed the movie player to the scripting API for advanced display features
- Various OpenGL optimizations for better graphics performance:
- Animations now use texture arrays
- Model uniforms get sent to the GPU using uniform buffers for less overhead
- Various other minor changes
- Converted pilot files from custom binary format to JSON
- Replaced Blinn-Phong BRDF with GGX BRDF
### Fixed
- Refactored bitmap slot handling and removed the fixed upper limit on the number of bitmaps. No more bmpman corruption!
## [3.8.0] - 2017-08-22 ([Release Thread](https://www.hard-light.net/forums/index.php?topic=93812.0))
### Added
- Support for APNG animations: [APNG](https://en.wikipedia.org/wiki/APNG) is a variant of the established PNG format which allows to store animations instead of single frames in a PNG file. This change allows to use these animation files in FSO which significantly improves usability for modders since they no longer have to store all individual frames as separate images.
- Physically-Based Rendering (PBR): This upgrade of our rendering engine allows to use [PBR](https://en.wikipedia.org/wiki/Physically_based_rendering) assets to make models look more realistic and allow more artistic freedom for modders since they have more control over how a model looks. This also added support for HDR lighting which should improve the overall graphics experience.
- Native particle systems: Particles have always been supported by FSO but the effects that could be created by them were very limited. There were some attempts to fix this by using Lua scripting for more advanced features but that suffered from performance issues. With these new particle systems that feature has been integrated directly into the engine which should improve performance and allow for better effects in the future.
- TrueType Font support: [TrueType](https://en.wikipedia.org/wiki/TrueType) fonts improve the text rendering capabilities of FSO by allowing to use freely scaleable font faces instead of the previous bitmap fonts.
### Changed
- We now use SDL2 on all platforms: SDL is a library for abstracting away the differences between different platforms. We now use SDL2 for all platforms which reduces the amount of platform-specific code tremendously and should result in better usability on all platforms. This was a major change that has been in development for several years. Here are a few key features that were added:
- Pilot and configuration data is now stored in the correct location across all platforms (this allows to run FSO on Windows from the Program Files directory without administrator rights)
- All platforms now use the ini files for storing settings. This fixes a lot of issues with the registry on Windows.
- Better support for input devices. Since SDL handles keyboard, mouse and joystick input we now have better support on newer OS versions. Note: This does not mean that we support multiple joysticks (yet). There is ongoing development effort to support this but this release does not have that yet.
- CMake build system generation: This isn't relevant for players but we are now using [CMake](https://en.wikipedia.org/wiki/CMake) for handling compiling our builds. This improves cross-platform support and allows to implement advanced compilation features across multiple platforms. Modders will like the new "FastDebug" builds which are like the previous "Debug" builds but are compiled with all the optimizations of normal Release builds. That should make modding a lot easier since you can now debug your mod with almost the same performance as a Release build.
- Improved shield effects: Rendering of the shields is now handled by special shaders which improves the overall quality of the effects and allows more freedom for future effects.
- Use OpenGL Core Profile for rendering: This is another major graphical upgrade which adds support for the OpenGL Core profile across all platforms (this was also made possible by the SDL2 integration). This upgrade allows us to use more modern rendering techniques and is especially useful for our Linux users who use the open-source Mesa drivers since our shaders failed to compile with those drivers. Now everyone will be able to enjoy the new graphical features added in this and previous releases. This also made some internal changes to how we handle rendering which improves the usability of our rendering engine within our code.
- Use FFmpeg for video & audio decoding: [FFmpeg](https://www.ffmpeg.org/) is a multi-media library which exposes functionality for decoding video and audio files to their raw form so that we can use that data. Thanks to this library we can now play 1080p cutscenes without any stuttering or frame-timing issues. It also allows to use more advanced audio and video codecs such as H.264 for video or Opus for audio.
## [3.7.4] - 2016-07-04 ([Release thread](http://www.hard-light.net/forums/index.php?topic=92181.0))
### Changed
- Major graphics update including deferred lighting and shadows
- Enhanced sound (up to 128 channels)
### Fixed
- "Tons" of bugfixes
## [3.7.2] - 2015-04-23 ([Release thread](http://www.hard-light.net/forums/index.php?topic=89597.0))
### Added
- MediaVPS 2014 Support
- Autospread on model point shields
- WebUI based multiplayer standalone server (for non-Windows platforms)
- Toggle subsytem scanning, scannable, cargo revealed, hidden from sensors, stealth and friendly stealth added to the `alter-ship-flag` SEXP
- Support added to add more languages besides English, French, German and Polish, leading the way to better localization!
- `player-is-cheating` SEXP
- New ship flag to enable smarter AI use of afterburners. Now it can use them while flying waypoints or attacking capital ships (use the `free-afterburner-use` flag with `alter-ship-flag`)
- Experimental configurations to make AVX builds (see [this post](http://www.hard-light.net/forums/index.php?topic=85566.0) for more explanations)
- Frame profiling code, see what exactly is slowing down FreeSpace. (Mostly for devs or coders)
### Changed
- Unstretched interface screens
- Automatically non stretched HUD gauges and simpler modder options for placing HUD gauges
- `show-subtitle-text` can now display messages as well as raw text
- Allow a user-specified number of credit images
- event.log can now snapshot events checked in a frame and record the status of an event the previous time it was checked as well as the current state
- Allow the specification of the positions of medals, callsigns and labels on the medal screen.
- The number of medals is now dynamic!
- `is-facing` now works for things that aren't ships (like waypoints!)
- allowing `fade-in` and `fade-out` sexps to use any color, not just black, white and red.
## [3.7.0] - 2013-08-31 ([Release thread](http://www.hard-light.net/forums/index.php?topic=85435.0))
### Major Change
- New Flexible Pilot Save File Code (combines single/multi pilots & allows safe switching between unfinished campaigns)
### Changed
- Raised the per-model debris limit to 48 (previously 32).
- Increased the per-frame debris limit to 96 (previously 64)
## [3.6.18] - 2013-03-01 ([Release thread](http://www.hard-light.net/forums/index.php?topic=83889.0))
### Fixed
- Critical damage bug which caused heavy balance issues in the game
## [3.6.16] - 2013-01-31 ([Release thread](http://www.hard-light.net/forums/index.php?topic=83577.0))
### Added
- Diaspora TC support
### Changed
- Performance Improvements
## [3.6.14] - 2012-10-23 - ([Release thread](https://www.hard-light.net/forums/index.php?topic=82648.0))
### Added
- Objecttype tables support for deciding how enemies respond to ship classes when disabled
- Allow modders to set a [mood](http://www.hard-light.net/forums/index.php?topic=81991.msg1639770#msg1639770) for builtin messages and then switch the mood for the mission on the fly using a SEXP
- Allow modders to set the chance of builtin messages being sent, how many will be sent per mission and how long is the delay between two messages
- Allow campaigns to be hidden in the campaign and tech rooms ([Game settings.tbl](https://wiki.hard-light.net/index.php/Game_settings.tbl#.23Ignored_Campaign_File_Names))
- Allow mods to set a default campaign ([Game settings.tbl](https://wiki.hard-light.net/index.php/Game_settings.tbl#.24Default_Campaign_File_Name:))
- New SEXPs
- `set-player-orders`
- `is-event\goal-true\false-msecs-delay`
- `get\set-num-countermeasures`
- `directive-value`
- `invalidate-all-arguments`
- `validate-all-arguments`
- `has-primary-weapon`
- `has-secondary-weapon`
- [`hud-display-gauge`](http://www.hard-light.net/forums/index.php?topic=68837.msg1361711#msg1361711)
- `get-object-speed-x`
- `get-object-speed-y`
- `get-object-speed-z`
### Changed
- Major HUD gauges overhaul
- Split the Locked flag so that you can lock Ships or Weapons on the game loadout screen independently
- Mixed ammo for primary and secondary weapons - [`$Substitute`](http://www.hard-light.net/wiki/index.php/Weapons.tbl#.24Substitute:) - Allows you to have a weapon that fires other weapon ammo in a specific pattern (say a Gatling gun with tracers).
- [`show-subtitle`](https://wiki.hard-light.net/index.php/SCP_SEXPs#show-subtitle) SEXP supports custom fonts
- The active support ship limit per side is now dynamic. See [`set-support-ship`](https://wiki.hard-light.net/index.php/SCP_SEXPs#set-support-ship) for more info.
### Fixed
- Various multiplayer SEXP fixes
- `rotating-subsys-set-time` now accelerates properly
- [Fixed a whole heap of memory, logic and coding errors](http://www.hard-light.net/forums/index.php?topic=78044.0) -- using PVS-Studio: C/C++ source code analysis and checking tool
----
## [Older Changes] - Unformatted
```
ChangeLog for fs2_open. All times are UTC.
Features: September 2013
http://www.hard-light.net/forums/index.php?topic=85700.0
- show-subtitle-text can now display messages as well as raw text - Goober5000
- toggle subsytem scanning, scannable, cargo revealed, hidden from sensors, stealth and friendly stealth added to the alter-ship-flag sexp - karajorma
- Support added to add more languages besides English, French, German and Polish, leading the way to better localization! - karajorma
- event.log can now snapshot events checked in a frame and record the status of an event the previous time it was checked as well as the current state - karajorma
- added a player-is-cheating sexp - The E
- allow a user-specified number of credit images - Goober5000
- allow the specification of the positions of medals, callsigns and labels on the medal screen. - Goober5000
- lua function to check if a ship is warp capable, and access to a ship's auto-aim FOV - zookeeper
- is-facing now works for things that aren't ships (like waypoints!) - zookeeper
- experimental configurations to make AVX builds (see this post for more explainations) - The E
- new ship flag to enable smarter AI use of afterburners. Now it can use them while flying waypoints or attacking capital ships (use the free-afterburner-use flag with alter-ship-flag) - Admiral MS
- the number of medals is now dynamic! - Goober5000
- frame profiling code, see what exactly is slowing down FreeSpace. (Mostly for devs or coders) - Swifty + The E
- allowing fade-in and fade-out sexps to use any color, not just black, white and red. - Goober5000
==================================================================
( massive gap in updates, maybe this will be filled in someday...)
==================================================================
@@ -351,7 +459,7 @@ http://www.hard-light.net/forums/index.php?topic=85700.0
(2.1.2.4), weapon/weapons.cpp (2.1.2.2):
Sorted out some bits and pieces. The background nebula blends now
which is nice. – RT
which is nice. – RT
2002-09-28 12:20 randomtiger
@@ -1886,3 +1994,4 @@ NOTE:
# generated by cvs2cl.pl
# cvs2cl.pl -r -S --utc -f ChangeLog2
```
+5 -4
View File
@@ -1,14 +1,15 @@
Volition Copyright (applies to original FreeSpace2 source code
developed and released by Volition):
"Copyright (C) Volition, Inc. 1999. All rights reserved.
All source code herein is the property of Volition, Inc. You may not
>Copyright (C) Volition, Inc. 1999. All rights reserved.
>
>All source code herein is the property of Volition, Inc. You may not
sell or otherwise commercially exploit the source or things you
created based on the source."
created based on the source.
Modifications by members of the FreeSpace Source Code Project are
released under whatever terms the individual authors choose, but the
above notice continues to apply to all fs2_open code.
See [**Licensing**](https://github.com/scp-fs2open/fs2open.github.com/wiki/Licensing) for more information.
Binary file not shown.
-29
View File
@@ -1,29 +0,0 @@
This is still in pretty rough form.
=== for people building fs2_open:
Win32-MSVC:
Use the Freespace2.dsw workspace and build within the IDE.
Win32-MinGW:
make
Linux and other unix variants (NOT YET COMPLETE)
./configure [options]
make
=== for the project maintainers (people who need to
=== keep the makefiles up to date) and those building
=== from CVS:
./autogen.sh (should only has to be done once)
./configure [options]
make
automake v1.6.1+ and
autoconf v2.54+ are required
+1 -32
View File
@@ -7,36 +7,5 @@ FreeSpace2 *S*ource *C*ode *P*roject
Building
--
Before you do anything, make sure you have updated your git submodules, either by running `git submodule update --init --recursive` or by cloning the repository with the `--recursive` flag.<br/>
<br/>
For building you will need [CMake](http://www.cmake.org/cmake/resources/software.html). Version 3.4 is required. Once you have installed CMake you should create a build directory where the project/make files should be created, **do not create them inside the source tree!**<br>
<br>
On Windows you can use the `cmake-gui` executable to get a nice GUI, on Unix just use `cmake`. Use the newly created directory as build directory (change to this directory on Unix) and run cmake. On Windows this can be done by clicking the `Configure` button. Choose your compiler version and hit `Generate` when configuring is done. <br>
Depending on the makefile generator used build the `all` or `ALL_BUILD` target to compile the project.<br>
### Available variables to control the build
* `FSO_BUILD_WXFRED2`: Build the wxfred2 project, requires wxWidgets
* `FSO_FREESPACE_PATH`: Sets the path of your FreeSpace install, can be used to automatically run the generated executables with the correct working directory, this is an optional variable. By default this will use the value of the `FS2PATH` environment variable.
* `FSO_BUILD_TOOLS`: Build some tools related to FSO
* `CMAKE_BUILD_TYPE`: Sets the binary build type between `Debug` and `Release` (default)
#### Windows only variables
* `FSO_BUILD_FRED2`: Build FRED2, requires a Visual Studio version that ships with MFC
* `FSO_USE_SPEECH`: Build a binary with text-to-speech support
* `FSO_USE_VOICEREC`: Build a binary with voice recognition support
#### Advanced variables
You should only use these variables if you know what you're doing
* `FSO_CMAKE_DEBUG`: Print CMake debugging informations
* `FSO_BUILD_INCLUDED_LIBS`: Build libraries from the included source
* `FSO_USE_OPENALSOFT`: Use [OpenALSoft](http://kcat.strangesoft.net/openal.html) for OpenAL support
* `FSO_USE_LUAJIT`: Use [luajit](http://luajit.org/) as a replacement for lua
* `FSO_DEVELOPMENT_MODE`: Toggles some development behavior, only use if you really need it.
* `FSO_RUN_ARGUMENTS`: If you run an executable from within the project, these arguments will also be passed to the executable
* `FSO_BUILD_POSTFIX`: Sets a postfix to be added to the executable name, may be useful for release candidates.
#### Visual Studio specific variables
* `MSVC_USE_RUNTIME_DLL`: Use the DLL version of the runtime, experimental and not well tested.
* `MSVC_SIMD_INSTRUCTIONS`: The instruction set the executables will be optimized for.
### Generating an installation package
CMake can automatically generate installation packages of the project. To do this you will just need to run the `package` target of the build system and the package will be placed inside your build directory. On Windows you will have to install [NSIS](http://nsis.sourceforge.net/Main_Page) to use this.
The main instructions for building can be found at our github wiki, on the [Building](https://github.com/scp-fs2open/fs2open.github.com/wiki/Building) page.
+18
View File
@@ -0,0 +1,18 @@
#Updating Documentation
####The goal of this file is simply to offer a comprehensive checklist of things we must check when updating the documentation.
1. Changelog:
- Is [Changelog.md](https://github.com/scp-fs2open/fs2open.github.com/blob/master/Changelog.md) up-to-date with the latest release?
- Is it in the proper [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format?
2. Build instructions:
- If a programmer who never built FSO before read the build instruction at [Readme.md](https://github.com/scp-fs2open/fs2open.github.com/blob/master/Readme.md), would they manage to build FSO?
- Is the information in the file up-to-date regarding other matters (such as versions of tools mentioned, links to other guides, etc.)?
- Is the information in the [Building](https://github.com/scp-fs2open/fs2open.github.com/wiki/Building) article, and its sub-articles, still up-to-date?
3. Forums:
- Does the [Forum](https://www.hard-light.net/forums/index.php?board=50.0) contain enough clear information to help a new developer find their way into the up-to-date instructions?
- Is there anything that might mislead a new developer to stumble onto old tools, dead links and/or old versions of the project?
4. General documentation files:
- Is the information in the following files up-to-date?
- [About.md](https://github.com/scp-fs2open/fs2open.github.com/blob/master/About.md) (Should contain general information about FS, FS2, HLP, FSO and FSU)
- [Authors.md](https://github.com/scp-fs2open/fs2open.github.com/blob/master/Authors.md) (Should contain information about the original developers, a way to see FSO's contributors, and special thanks to Volition and Dave Baranec)
- [Copying.md](https://github.com/scp-fs2open/fs2open.github.com/blob/master/Copying.md) (Should contain Volition's Copyright terms and a way to check FSO's Licensing info)
+18 -19
View File
@@ -1,4 +1,5 @@
version: 1.0.0.{build}
image: Visual Studio 2015
configuration:
- Debug
- Release
@@ -6,13 +7,13 @@ clone_depth: 10
environment:
matrix:
- BuildID: 0
CMAKE_GENERATOR: Visual Studio 12 2013
PlatformToolset: v120_xp
QT_DIR: C:\Qt\5.7\msvc2013
CMAKE_GENERATOR: Visual Studio 14 2015
PlatformToolset: v140_xp
QT_DIR: C:\Qt\5.9\msvc2015
- BuildID: 1
CMAKE_GENERATOR: Visual Studio 14 2015 Win64
PlatformToolset: v140_xp
QT_DIR: C:\Qt\5.7\msvc2015_64
QT_DIR: C:\Qt\5.9\msvc2015_64
before_build:
- git submodule update --init --recursive
build_script:
@@ -23,7 +24,7 @@ test_script:
deploy:
- provider: GitHub
auth_token:
secure: 3kV4efHXwRnfXzmJPRAOs8D7+MhwXUXYeayI/P5y114L09kJa6b6L70beXdW7yYr
secure: h55Scpy+3vmo1Yb7WlSIGA4d9DRnsbzUYc2LYsQdByQHZHbqrqjBpicH0D2FFLEO
on:
ReleaseBuild: true # deploy on release push only
@@ -39,25 +40,23 @@ deploy:
NightlyBuild: true # deploy on nightly push only
- provider: FTP
protocol: ftp
host: swc.fs2downloads.com
username:
secure: EXg2ADoKzMduZF90ip2Q0g==
protocol: sftp
host: porphyrion.feralhosting.com
username:
secure: 36+bVD8eJgI0BVbi7TZ4zQ==
password:
secure: x0LL0uY9yBAQ7JTARhQ6AA==
folder: swc.fs2downloads.com/builds/nightly/$(VersionName)
beta: true
secure: CrzmDVca8AGG08iWPA1gOD4Ge06+wJ3rcBagBGclwYQ=
folder: www/datacorder.porphyrion.feralhosting.com/public_html/builds/nightly/$(VersionName)
on:
NightlyBuild: true # deploy on nightly push only
- provider: FTP
protocol: ftp
host: swc.fs2downloads.com
username:
secure: EXg2ADoKzMduZF90ip2Q0g==
protocol: sftp
host: porphyrion.feralhosting.com
username:
secure: 36+bVD8eJgI0BVbi7TZ4zQ==
password:
secure: x0LL0uY9yBAQ7JTARhQ6AA==
folder: swc.fs2downloads.com/builds/test/$(VersionName)
beta: true
secure: CrzmDVca8AGG08iWPA1gOD4Ge06+wJ3rcBagBGclwYQ=
folder: www/datacorder.porphyrion.feralhosting.com/public_html/builds/test/$(VersionName)
on:
TestBuild: true # deploy on test build push only
+13 -8
View File
@@ -14,7 +14,7 @@ $NightlyConfigurations = @(
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.7\msvc2015_64";
QtDir="C:\Qt\5.9\msvc2015_64";
SourcePackage=$false;
},
[BuildConfig]@{
@@ -22,7 +22,7 @@ $NightlyConfigurations = @(
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.7\msvc2015";
QtDir="C:\Qt\5.9\msvc2015";
SourcePackage=$false;
}
)
@@ -32,7 +32,7 @@ $ReleaseConfigurations = @(
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.7\msvc2015";
QtDir="C:\Qt\5.9\msvc2015";
SourcePackage=$true;
}
[BuildConfig]@{
@@ -40,7 +40,7 @@ $ReleaseConfigurations = @(
PackageType="Win32-AVX";
Toolset="v140_xp";
SimdType="AVX";
QtDir="C:\Qt\5.7\msvc2015";
QtDir="C:\Qt\5.9\msvc2015";
SourcePackage=$false;
}
[BuildConfig]@{
@@ -48,7 +48,7 @@ $ReleaseConfigurations = @(
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.7\msvc2015_64";
QtDir="C:\Qt\5.9\msvc2015_64";
SourcePackage=$false;
}
[BuildConfig]@{
@@ -56,7 +56,7 @@ $ReleaseConfigurations = @(
PackageType="Win64-AVX";
Toolset="v140_xp";
SimdType="AVX";
QtDir="C:\Qt\5.7\msvc2015_64";
QtDir="C:\Qt\5.9\msvc2015_64";
SourcePackage=$false;
}
)
@@ -133,6 +133,8 @@ if ($DeployBuild) {
cmake -DCMAKE_INSTALL_PREFIX="$env:APPVEYOR_BUILD_FOLDER/../install" -DFSO_USE_SPEECH="ON" `
-DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS="$($buildConfig.SimdType)" `
-DQT5_INSTALL_ROOT="$($buildConfig.QtDir)" -DFSO_BUILD_QTFRED=ON `
-DFSO_INSTALL_DEBUG_FILES="ON" `
-G "$($buildConfig.Generator)" -T "$($buildConfig.Toolset)" ..
$Configs = @("Release", "FastDebug")
@@ -144,11 +146,14 @@ if ($DeployBuild) {
}
}
7z a "$($PackageName)-builds-$($buildConfig.PackageType).zip" "$env:APPVEYOR_BUILD_FOLDER/../install/*"
7z a -xr'!*.pdb' "$($PackageName)-builds-$($buildConfig.PackageType).zip" "$env:APPVEYOR_BUILD_FOLDER/../install/*"
Push-AppveyorArtifact "$($PackageName)-builds-$($buildConfig.PackageType).zip"
7z a "$($PackageName)-debug-$($buildConfig.PackageType).7z" "$env:APPVEYOR_BUILD_FOLDER/../install/*.pdb"
Push-AppveyorArtifact "$($PackageName)-debug-$($buildConfig.PackageType).7z"
} else {
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="ON" -DFSO_BUILD_TESTS="ON" -DMSVC_SIMD_INSTRUCTIONS=SSE2 `
-DFSO_BUILD_QTFRED=ON -DQT5_INSTALL_ROOT="$env:QT_DIR" -DFSO_BUILD_FRED2="OFF" `
-DFSO_BUILD_QTFRED=ON -DQT5_INSTALL_ROOT="$env:QT_DIR" -DFSO_BUILD_FRED2="ON" `
-G "$Env:CMAKE_GENERATOR" -T "$Env:PlatformToolset" ..
cmake --build . --config "$Env:CONFIGURATION" -- /verbosity:minimal
+11 -2
View File
@@ -3,9 +3,18 @@
set -ex
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
# Nothing to do here
:
export DEBIAN_FRONTEND=noninteractive
sudo add-apt-repository -y "ppa:msulikowski/valgrind" # For fixing a bug with valgrind 3.11 which does not recognize the rdrand instruction
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo add-apt-repository -y 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
sudo apt-get -yq update
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
# Nothing to do here
:
elif [ "$TRAVIS_OS_NAME" = "windows" ]; then
# Nothing to do here
:
fi
+18 -11
View File
@@ -2,22 +2,22 @@
set -ex
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
mkdir -p /tmp/builds
if [ "$RELEASE_BUILD" = true ]; then
# Package the source code in release builds
PARENT_DIR="$(basename "$PWD")"
(cd .. && tar -czvf /tmp/builds/$PACKAGE_NAME-source-Unix.tar.gz --exclude-vcs "$PARENT_DIR")
fi
fi
mkdir -p build
cd build
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
if [ "$RELEASE_BUILD" = true ]; then
PARENT_DIR="$(basename $PWD)"
(cd .. && tar -czvf /tmp/builds/$PACKAGE_NAME-source-Unix.tar.gz --exclude-vcs "$PARENT_DIR")
fi
CXXFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
CFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
if [[ "$CC" =~ ^clang.*$ ]]; then
CXXFLAGS="$CXXFLAGS -stdlib=libc++"
fi
export CXXFLAGS
export CFLAGS
CMAKE="cmake -G Ninja -DFSO_FATAL_WARNINGS=ON $CMAKE_OPTIONS"
@@ -27,8 +27,7 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
mkdir -p $config
cd $config
eval $CMAKE -DFSO_INSTALL_DEBUG_FILES=ON -DCMAKE_BUILD_TYPE=$config -DCMAKE_INSTALL_PREFIX="/tmp/release/$config" \
-DFSO_BUILD_APPIMAGE=ON -DAPPIMAGE_ASSISTANT="$HOME/AppImageAssistant" \
-DFSO_BUILD_INCLUDED_LIBS=ON -DFFMPEG_USE_PRECOMPILED=ON ../..
-DFSO_BUILD_APPIMAGE=ON -DFSO_BUILD_INCLUDED_LIBS=ON -DFFMPEG_USE_PRECOMPILED=ON -DFSO_BUILD_QTFRED=OFF ../..
cd ..
done
else
@@ -40,4 +39,12 @@ elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
else
cmake -G "Xcode" $CMAKE_OPTIONS ..
fi
elif [ "$TRAVIS_OS_NAME" = "windows" ]; then
if [ "$CMAKE_GENERATOR" = "Ninja" ]; then
cmake -DFSO_USE_SPEECH="OFF" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
-DFSO_BUILD_FRED2="OFF" -G "$CMAKE_GENERATOR" ..
else
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="OFF" -DFSO_BUILD_TESTS="ON" \
-DMSVC_SIMD_INSTRUCTIONS=SSE2 -DFSO_BUILD_FRED2="ON" -G "$CMAKE_GENERATOR" -T "$CMAKE_TOOLSET" ..
fi
fi
+5
View File
@@ -58,6 +58,11 @@ if [ "$BUILD_DEPLOYMENT" = true ]; then
echo "Skipping non-release configuration";
exit 0;
fi
if [ "$TRAVIS_OS_NAME" = "windows" ]; then
echo "Skipping non-release platform"
exit 0
fi
fi
export RELEASE_BUILD
+268
View File
@@ -0,0 +1,268 @@
#!/usr/bin/env python
#
#===- clang-tidy-diff.py - ClangTidy Diff Checker ------------*- python -*--===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
r"""
ClangTidy Diff Checker
======================
This script reads input from a unified diff, runs clang-tidy on all changed
files and outputs clang-tidy warnings in changed lines only. This is useful to
detect clang-tidy regressions in the lines touched by a specific patch.
Example usage for git/svn users:
git diff -U0 HEAD^ | clang-tidy-diff.py -p1
svn diff --diff-cmd=diff -x-U0 | \
clang-tidy-diff.py -fix -checks=-*,modernize-use-override
"""
import argparse
import glob
import json
import multiprocessing
import os
import re
import shutil
import subprocess
import sys
import tempfile
import threading
import traceback
try:
import yaml
except ImportError:
yaml = None
is_py2 = sys.version[0] == '2'
if is_py2:
import Queue as queue
else:
import queue as queue
def run_tidy(task_queue, lock, timeout):
watchdog = None
while True:
command = task_queue.get()
try:
proc = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
if timeout is not None:
watchdog = threading.Timer(timeout, proc.kill)
watchdog.start()
stdout, stderr = proc.communicate()
with lock:
sys.stdout.write(stdout.decode('utf-8'))
sys.stdout.flush()
if stderr:
sys.stderr.write(stderr.decode('utf-8'))
sys.stderr.flush()
except Exception as e:
with lock:
sys.stderr.write('Failed: ' + str(e) + ': '.join(command) + '\n')
finally:
with lock:
if (not timeout is None) and (not watchdog is None):
if not watchdog.is_alive():
sys.stderr.write('Terminated by timeout: ' +
' '.join(command) + '\n')
watchdog.cancel()
task_queue.task_done()
def start_workers(max_tasks, tidy_caller, task_queue, lock, timeout):
for _ in range(max_tasks):
t = threading.Thread(target=tidy_caller, args=(task_queue, lock, timeout))
t.daemon = True
t.start()
def merge_replacement_files(tmpdir, mergefile):
"""Merge all replacement files in a directory into a single file"""
# The fixes suggested by clang-tidy >= 4.0.0 are given under
# the top level key 'Diagnostics' in the output yaml files
mergekey = "Diagnostics"
merged = []
for replacefile in glob.iglob(os.path.join(tmpdir, '*.yaml')):
content = yaml.safe_load(open(replacefile, 'r'))
if not content:
continue # Skip empty files.
merged.extend(content.get(mergekey, []))
if merged:
# MainSourceFile: The key is required by the definition inside
# include/clang/Tooling/ReplacementsYaml.h, but the value
# is actually never used inside clang-apply-replacements,
# so we set it to '' here.
output = { 'MainSourceFile': '', mergekey: merged }
with open(mergefile, 'w') as out:
yaml.safe_dump(output, out)
else:
# Empty the file:
open(mergefile, 'w').close()
def main():
parser = argparse.ArgumentParser(description=
'Run clang-tidy against changed files, and '
'output diagnostics only for modified '
'lines.')
parser.add_argument('-clang-tidy-binary', metavar='PATH',
default='clang-tidy',
help='path to clang-tidy binary')
parser.add_argument('-p', metavar='NUM', default=0,
help='strip the smallest prefix containing P slashes')
parser.add_argument('-regex', metavar='PATTERN', default=None,
help='custom pattern selecting file paths to check '
'(case sensitive, overrides -iregex)')
parser.add_argument('-iregex', metavar='PATTERN', default=
r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hpp|m|mm|inc)',
help='custom pattern selecting file paths to check '
'(case insensitive, overridden by -regex)')
parser.add_argument('-j', type=int, default=1,
help='number of tidy instances to be run in parallel.')
parser.add_argument('-timeout', type=int, default=None,
help='timeout per each file in seconds.')
parser.add_argument('-fix', action='store_true', default=False,
help='apply suggested fixes')
parser.add_argument('-checks',
help='checks filter, when not specified, use clang-tidy '
'default',
default='')
parser.add_argument('-path', dest='build_path',
help='Path used to read a compile command database.')
if yaml:
parser.add_argument('-export-fixes', metavar='FILE', dest='export_fixes',
help='Create a yaml file to store suggested fixes in, '
'which can be applied with clang-apply-replacements.')
parser.add_argument('-extra-arg', dest='extra_arg',
action='append', default=[],
help='Additional argument to append to the compiler '
'command line.')
parser.add_argument('-extra-arg-before', dest='extra_arg_before',
action='append', default=[],
help='Additional argument to prepend to the compiler '
'command line.')
parser.add_argument('-quiet', action='store_true', default=False,
help='Run clang-tidy in quiet mode')
clang_tidy_args = []
argv = sys.argv[1:]
if '--' in argv:
clang_tidy_args.extend(argv[argv.index('--'):])
argv = argv[:argv.index('--')]
args = parser.parse_args(argv)
# Extract changed lines for each file.
filename = None
lines_by_file = {}
for line in sys.stdin:
match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\n\"]*)' % args.p, line)
if match:
filename = match.group(2)
if filename is None:
continue
if args.regex is not None:
if not re.match('^%s$' % args.regex, filename):
continue
else:
if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE):
continue
match = re.search('^@@.*\+(\d+)(,(\d+))?', line)
if match:
start_line = int(match.group(1))
line_count = 1
if match.group(3):
line_count = int(match.group(3))
if line_count == 0:
continue
end_line = start_line + line_count - 1
lines_by_file.setdefault(filename, []).append([start_line, end_line])
if not any(lines_by_file):
print("No relevant changes found.")
sys.exit(0)
max_task_count = args.j
if max_task_count == 0:
max_task_count = multiprocessing.cpu_count()
max_task_count = min(len(lines_by_file), max_task_count)
tmpdir = None
if yaml and args.export_fixes:
tmpdir = tempfile.mkdtemp()
# Tasks for clang-tidy.
task_queue = queue.Queue(max_task_count)
# A lock for console output.
lock = threading.Lock()
# Run a pool of clang-tidy workers.
start_workers(max_task_count, run_tidy, task_queue, lock, args.timeout)
# Form the common args list.
common_clang_tidy_args = []
if args.fix:
common_clang_tidy_args.append('-fix')
if args.checks != '':
common_clang_tidy_args.append('-checks=' + args.checks)
if args.quiet:
common_clang_tidy_args.append('-quiet')
if args.build_path is not None:
common_clang_tidy_args.append('-p=%s' % args.build_path)
for arg in args.extra_arg:
common_clang_tidy_args.append('-extra-arg=%s' % arg)
for arg in args.extra_arg_before:
common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
for name in lines_by_file:
line_filter_json = json.dumps(
[{"name": name, "lines": lines_by_file[name]}],
separators=(',', ':'))
# Run clang-tidy on files containing changes.
command = [args.clang_tidy_binary]
command.append('-line-filter=' + line_filter_json)
if yaml and args.export_fixes:
# Get a temporary file. We immediately close the handle so clang-tidy can
# overwrite it.
(handle, tmp_name) = tempfile.mkstemp(suffix='.yaml', dir=tmpdir)
os.close(handle)
command.append('-export-fixes=' + tmp_name)
command.extend(common_clang_tidy_args)
command.append(name)
command.extend(clang_tidy_args)
task_queue.put(command)
# Wait for all threads to be done.
task_queue.join()
if yaml and args.export_fixes:
print('Writing fixes to ' + args.export_fixes + ' ...')
try:
merge_replacement_files(tmpdir, args.export_fixes)
except:
sys.stderr.write('Error exporting fixes.\n')
traceback.print_exc()
if tmpdir:
shutil.rmtree(tmpdir)
if __name__ == '__main__':
main()
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -e
if ! git rev-list $TRAVIS_COMMIT_RANGE 2>1 >/dev/null; then
echo "\$TRAVIS_COMMIT_RANGE ($TRAVIS_COMMIT_RANGE) is not valid for this build (probably caused by a rebase)."
exit 0
fi
cd "$TRAVIS_BUILD_DIR"
echo "Running clang-tidy on changed files"
git diff -U0 --no-color $TRAVIS_COMMIT_RANGE | \
$TRAVIS_BUILD_DIR/ci/travis/clang-tidy-diff.py -path "$TRAVIS_BUILD_DIR/build" -p1 \
-regex '(code|freespace2|qtfred|testsrc|build|tools)\/.*\.(cpp|h)' \
-clang-tidy-binary /usr/bin/clang-tidy-9 -j$(nproc) -quiet 2>/dev/null | \
tee clang-tidy-output.txt
if [[ -n $(grep "warning: " clang-tidy-output.txt) ]] || [[ -n $(grep "error: " clang-tidy-output.txt) ]]; then
echo "Errors or warnings were detected in the clang-tidy output!"
exit 1
else
echo -e "\033[1;32m\xE2\x9C\x93 passed:\033[0m clang-tidy test succeeded";
fi
+57 -22
View File
@@ -10,27 +10,62 @@ if [[ ! "$(curl -V)" == *"sftp"* ]]; then
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
# Since the Travis CI people are not capable of enabling SSH/SCP support for their libcurl we need to build that manually...
# These commands are based on the tutorial from here: http://zeroset.mnim.org/2013/03/14/sftp-support-for-curl-in-ubuntu-12-10-quantal-quetzal-and-later/
mkdir /tmp/curl
cd /tmp/curl
sudo apt-get update
sudo apt-get install build-essential debhelper libssh2-1-dev libgnutls-dev libidn11-dev libkrb5-dev libldap2-dev libnss3-dev librtmp-dev libtool openssh-server quilt
apt-get source curl
sudo apt-get build-dep curl
if [ -f ~/curl_cache/curl*.deb ]; then
cd ~/curl_cache
sudo dpkg -i libcurl3*.deb
sudo dpkg -i curl*.deb
else
# Since the Travis CI people are not capable of enabling SSH/SCP support for their libcurl we need to build that manually...
# These commands are based on the tutorial from here: http://zeroset.mnim.org/2013/03/14/sftp-support-for-curl-in-ubuntu-12-10-quantal-quetzal-and-later/
mkdir /tmp/curl
cd /tmp/curl
sudo apt-get update
sudo apt-get install build-essential debhelper libssh2-1-dev libgnutls-dev libidn11-dev libkrb5-dev libldap2-dev libnss3-dev librtmp-dev libtool openssh-server quilt
apt-get source curl
sudo apt-get build-dep curl
cd curl-*
export DEB_BUILD_OPTIONS="nocheck"
sudo dpkg-buildpackage -uc -us -j"$(grep -c ^processor /proc/cpuinfo)"
cd curl-*
export DEB_BUILD_OPTIONS="nocheck"
sudo dpkg-buildpackage -uc -us -j"$(grep -c ^processor /proc/cpuinfo)"
cd ..
dpkg -l | grep curl
ls -al
sudo dpkg -i libcurl3*.deb
sudo dpkg -i curl*.deb
cd ..
dpkg -l | grep curl
ls -al
if [ ! -d ~/curl_cache ]; then
mkdir ~/curl_cache
fi
cp libcurl3*.deb curl*.deb ~/curl_cache
sudo dpkg -i libcurl3*.deb
sudo dpkg -i curl*.deb
fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
brew install curl --with-libssh2
export PATH="/usr/local/opt/curl/bin:$PATH"
brew install libssh2
if [ -d ~/curl_cache/curl ]; then
cd ~/curl_cache/curl
sudo make install
else
mkdir /tmp/curl
cd /tmp/curl
curl -LO "https://curl.haxx.se/download/curl-7.64.0.tar.bz2"
tar -xjf curl-7.64.0.tar.bz2
cd curl-7.64.0
./configure --disable-debug --disable-dependency-tracking --disable-silent-rules --with-libssh2 --with-darwinssl --without-ca-bundle --without-ca-path
make -j"$(sysctl hw.logicalcpu | cut -d " " -f 2)"
if [ ! -d ~/curl_cache ]; then
mkdir ~/curl_cache
fi
cp -a . ~/curl_cache/curl
sudo make install
fi
export PATH=/usr/local/bin:$PATH
fi
# After
@@ -42,13 +77,13 @@ cd /tmp/builds
for file in *; do
if [ "$TEST_BUILD" = true ]; then
# Upload to fs2downloads
curl -k "ftp://swc.fs2downloads.com/swc.fs2downloads.com/builds/test/$VERSION_NAME/" --user "$FS2DOWNLOADS_USER:$FS2DOWNLOADS_PASSWORD" -T "$file" --ftp-create-dirs
# Upload to datacorder
curl -k "sftp://porphyrion.feralhosting.com/www/datacorder.porphyrion.feralhosting.com/public_html/builds/test/$VERSION_NAME/" --user "$DATACORDER_USER:$DATACORDER_PASSWORD" -T "$file" --ftp-create-dirs
else
# Upload to indiegames
curl -k "sftp://scp.indiegames.us/~/public_html/builds/nightly/$VERSION_NAME/" --user "$INDIEGAMES_USER:$INDIEGAMES_PASSWORD" -T "$file" --ftp-create-dirs
# Upload to fs2downloads
curl -k "ftp://swc.fs2downloads.com/swc.fs2downloads.com/builds/nightly/$VERSION_NAME/" --user "$FS2DOWNLOADS_USER:$FS2DOWNLOADS_PASSWORD" -T "$file" --ftp-create-dirs
# Upload to datacorder
curl -k "sftp://porphyrion.feralhosting.com/~/www/datacorder.porphyrion.feralhosting.com/public_html/builds/nightly/$VERSION_NAME/" --user "$DATACORDER_USER:$DATACORDER_PASSWORD" -T "$file" --ftp-create-dirs
fi
done
+27 -9
View File
@@ -1,29 +1,47 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
set -ex
FILENAME=
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
if [ ! -d "$HOME/cmake-3.6/bin" ]; then
# If the cache does not currently contain CMake then download and install it
mkdir -p $HOME/cmake-3.6/
export DEBIAN_FRONTEND=noninteractive
wget -O /tmp/cmake.tar.gz --no-check-certificate https://cmake.org/files/v3.6/cmake-3.6.0-Linux-x86_64.tar.gz
tar -xzf /tmp/cmake.tar.gz -C $HOME/cmake-3.6/ --strip-components=1
if [ ! -d "$HOME/cmake-3.8/bin" ]; then
# If the cache does not currently contain CMake then download and install it
mkdir -p $HOME/cmake-3.8/
wget -O /tmp/cmake.tar.gz --no-check-certificate https://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.tar.gz
tar -xzf /tmp/cmake.tar.gz -C $HOME/cmake-3.8/ --strip-components=1
fi
export PATH=$HOME/cmake-3.6/bin:$PATH
export PATH=$HOME/cmake-3.8/bin:$PATH
cd $HOME
if [ "${BUILD_DEPLOYMENT}" = true ]; then
wget -c "https://github.com/probonopd/AppImageKit/releases/download/5/AppImageAssistant" # (64-bit)
chmod a+x ./AppImageAssistant
wget -O appimagetool -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" # (64-bit)
chmod a+x ./appimagetool
wget -O linuxdeployqt -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" # (64-bit)
chmod a+x ./linuxdeployqt
fi
sudo apt-get -yq install valgrind
if [[ "$CC" = "clang-9" ]]; then
sudo apt-get -yq install clang-9 clang-tidy-9
fi
if [[ "$CC" = "clang-4.0" ]]; then
# Fix a header bug present in ubuntu...
sudo ln -s /usr/include/libcxxabi/__cxxabi_config.h /usr/include/c++/v1/__cxxabi_config.h
fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
gem install xcpretty
brew update
brew outdated cmake || brew upgrade cmake
elif [ "$TRAVIS_OS_NAME" = "windows" ]; then
choco install mingw ninja
fi
cmake --version
+34 -1
View File
@@ -8,7 +8,40 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
for config in $BUILD_CONFIGS
do
cd "$config"
ninja appimage
# Compile all targets
ninja all
# Install Freespace2 targets
cmake -DCMAKE_INSTALL_PREFIX=/tmp/release/$config/fso -DCOMPONENT=Unspecified -P cmake_install.cmake
cmake -DCMAKE_INSTALL_PREFIX=/tmp/release/$config/fso -DCOMPONENT=Freespace2 -P cmake_install.cmake
# We need to be a bit creative for determining the AppImage name since we don't want to hard-code the name
FILENAME="$(find /tmp/release/$config/fso/bin -name 'fs2_open_*' -type f -printf "%f\n").AppImage"
$HOME/appimagetool -n /tmp/release/$config/fso "/tmp/release/$config/fso/$FILENAME"
: <<'END'
# Install qtFRED targets
cmake -DCMAKE_INSTALL_PREFIX=/tmp/release/$config/qtfred/usr -DCOMPONENT=Unspecified -P cmake_install.cmake
cmake -DCMAKE_INSTALL_PREFIX=/tmp/release/$config/qtfred/usr -DCOMPONENT=qtFRED -P cmake_install.cmake
PREV="$(pwd)"
cd /tmp/release/$config/qtfred
unset QTDIR; unset QT_PLUGIN_PATH; unset LD_LIBRARY_PATH
$HOME/linuxdeployqt usr/qtfred.desktop -bundle-non-qt-libs
# Move our AppRun script to the right location
mv usr/AppRun AppRun
echo "Embed newer libstdc++ for distros that don't come with it (ubuntu 14.04)";
mkdir -p usr/optional/; mkdir -p usr/optional/libstdc++/;
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ./usr/optional/libstdc++/;
$HOME/appimagetool -n . "$(find /tmp/release/$config/qtfred/usr/bin -name 'qtfred_*' -type f -printf "%f\n").AppImage"
cd "$PREV"
END
cd ..
done
+12 -2
View File
@@ -7,8 +7,12 @@ cd build
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
ninja -k 20 all
valgrind --leak-check=full --error-exitcode=1 --gen-suppressions=all \
--suppressions="$TRAVIS_BUILD_DIR/ci/travis/valgrind.supp" ./bin/unittests --gtest_shuffle
if [ "$CONFIGURATION" = "Debug" ]; then
valgrind --leak-check=full --error-exitcode=1 --gen-suppressions=all \
--suppressions="$TRAVIS_BUILD_DIR/ci/travis/valgrind.supp" ./bin/unittests --gtest_shuffle
else
./bin/unittests --gtest_shuffle
fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
cmake --build . --config "$CONFIGURATION" | tee build.log | xcpretty
XCODE_RET=${PIPESTATUS[0]}
@@ -17,4 +21,10 @@ elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
curl --upload-file build.log.tar.gz "https://transfer.sh/build.log.tar.gz"
exit $XCODE_RET
fi
elif [ "$TRAVIS_OS_NAME" = "windows" ]; then
if [ "$CMAKE_GENERATOR" = "Ninja" ]; then
cmake --build . --config "$CONFIGURATION"
else
cmake --build . --config "$CONFIGURATION" -- /verbosity:minimal
fi
fi
+137 -1
View File
@@ -25,4 +25,140 @@
fun:_dl_init
fun:dl_open_worker
fun:_dl_catch_error
}
}
{
CLang Lua unitialized value error
Memcheck:Cond
...
fun:luaH_get
fun:lua_rawget
fun:_ZN12_GLOBAL__N_117ade_index_handlerEP9lua_State
}
{
False-positive uninitialized variable warning
Memcheck:Cond
fun:_Z23cf_check_location_flagsjj
fun:_Z29cf_create_default_path_stringPcjiPKcbj
...
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:_Znwm
obj:*
obj:*
obj:*
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
fun:_Z7gr_initOSt10unique_ptrIN2os18GraphicsOperationsESt14default_deleteIS1_EEiiii
fun:_ZN4test13FSTestFixture5SetUpEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing4Test3RunEv
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:_Znwm
obj:*
obj:*
obj:*
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
fun:_Z7gr_initOSt10unique_ptrIN2os18GraphicsOperationsESt14default_deleteIS1_EEiiii
fun:_ZN4test13FSTestFixture5SetUpEv
fun:_ZN8FontTest5SetUpEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_Znwm
obj:*
obj:*
obj:*
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
fun:_Z7gr_initONSt3__110unique_ptrIN2os18GraphicsOperationsENS_14default_deleteIS2_EEEEiiii
fun:_ZN4test13FSTestFixture5SetUpEv
fun:_ZN8FontTest5SetUpEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_Znwm
obj:*
obj:*
obj:*
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
fun:_Z7gr_initONSt3__110unique_ptrIN2os18GraphicsOperationsENS_14default_deleteIS2_EEEEiiii
fun:_ZN4test13FSTestFixture5SetUpEv
fun:_ZN8FontTest5SetUpEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_Znwm
obj:*
obj:*
obj:*
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
obj:/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.4.0
fun:_Z7gr_initONSt3__110unique_ptrIN2os18GraphicsOperationsENS_14default_deleteIS2_EEEEiiii
fun:_ZN4test13FSTestFixture5SetUpEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_dl_signal_error
fun:_dl_open
fun:dlopen_doit
fun:_dl_catch_error
fun:_dlerror_run
fun:dlopen@@GLIBC_2.2.5
obj:*
obj:*
fun:call_init.part.0
fun:call_init
fun:_dl_init
fun:dl_open_worker
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_dl_signal_error
fun:_dl_open
fun:dlopen_doit
fun:_dl_catch_error
fun:_dlerror_run
fun:dlopen@@GLIBC_2.2.5
obj:*
obj:*
fun:call_init.part.0
fun:call_init
fun:_dl_init
fun:dl_open_worker
}
+3 -1
View File
@@ -1,4 +1,6 @@
[Desktop Entry]
Type=Application
Name=FreeSpace Open
Exec=$<TARGET_FILE_NAME:Freespace2>
Icon=app_icon.png
Icon=app_icon
Categories=Game;
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/sh
HERE=$(dirname $(readlink -f "${0}"))
export LD_LIBRARY_PATH="${HERE}"/lib:"$LD_LIBRARY_PATH"
"${HERE}"/bin/$<TARGET_FILE_NAME:Freespace2> $@
exec "${HERE}"/bin/$<TARGET_FILE_NAME:Freespace2> $@
+6 -8
View File
@@ -6,18 +6,16 @@ configure_file("${CMAKE_CURRENT_LIST_DIR}/AppRun.in" "${CMAKE_CURRENT_BINARY_DIR
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/AppRun.gen")
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>" DESTINATION "." RENAME "AppRun")
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>" DESTINATION "." RENAME "AppRun"
COMPONENT "Freespace2")
configure_file("${CMAKE_CURRENT_LIST_DIR}/AppImage.desktop.in" "${CMAKE_CURRENT_BINARY_DIR}/AppImage.desktop.gen" @ONLY)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/AppImage.desktop.gen")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop" DESTINATION "." RENAME "fso.desktop")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop" DESTINATION "." RENAME "fso.desktop"
COMPONENT "Freespace2")
install(FILES "${CMAKE_SOURCE_DIR}/freespace2/resources/app_icon.png" DESTINATION ".")
add_custom_target(appimage
COMMAND "${APPIMAGE_ASSISTANT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/fs2_open_${FSO_BINARY_SUFFIX}.AppImage")
add_dependencies(appimage install)
install(FILES "${CMAKE_SOURCE_DIR}/freespace2/resources/app_icon.png" DESTINATION "."
COMPONENT "Freespace2")
+1 -1
View File
@@ -3,7 +3,7 @@ INCLUDE(util)
MESSAGE(STATUS "Configuring UNIX specific things and stuff...")
target_compile_definitions(platform INTERFACE SCP_UNIX USE_OPENAL)
target_compile_definitions(platform INTERFACE SCP_UNIX USE_OPENAL _REENTRANT)
# Set RPATH
set(CMAKE_SKIP_BUILD_RPATH TRUE)
+1 -1
View File
@@ -8,7 +8,7 @@ SET(WIN32_LIBS
odbccp32
vfw32
winmm
wsock32
ws2_32
psapi
)
+11 -8
View File
@@ -10,8 +10,8 @@ include(CheckSymbolExists)
include(CheckCXXSymbolExists)
include(CheckTypeSize)
CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
CHECK_INCLUDE_FILE_CXX("cxxabi.h" HAVE_CXXAPI_H)
CHECK_INCLUDE_FILE("execinfo.h" SCP_HAVE_EXECINFO_H)
CHECK_INCLUDE_FILE_CXX("cxxabi.h" SCP_HAVE_CXXAPI_H)
CHECK_TYPE_SIZE("max_align_t" MAX_ALIGN_T)
@@ -31,15 +31,18 @@ CHECK_TYPE_SIZE("U'b'" UNICODE_CHAR_LITERAL LANGUAGE CXX)
set(CMAKE_REQUIRED_FLAGS)
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
CHECK_FUNCTION_EXISTS(strcasecmp SCP_HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS(strncasecmp SCP_HAVE_STRNCASECMP)
CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
CHECK_FUNCTION_EXISTS(_stricmp SCP_HAVE__STRICMP)
CHECK_FUNCTION_EXISTS(_strnicmp SCP_HAVE__STRNICMP)
CHECK_FUNCTION_EXISTS(strlwr HAVE_STRLWR)
CHECK_FUNCTION_EXISTS(strlwr SCP_HAVE_STRLWR)
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
CHECK_INCLUDE_FILE("strings.h" SCP_HAVE_STRINGS_H)
check_symbol_exists(snprintf "stdio.h" SCP_HAVE_SNPRINTF)
check_symbol_exists(_snprintf "stdio.h" SCP_HAVE__SNPRINTF)
set(PLATFORM_CHECK_HEADER "${GENERATED_SOURCE_DIR}/platformChecks.h")
CONFIGURE_FILE(${CMAKE_CURRENT_LIST_DIR}/platformChecks.h.in "${PLATFORM_CHECK_HEADER}")
+14 -12
View File
@@ -3,26 +3,28 @@
#define __PLATFORM_CHECKS_H__
#pragma once
#cmakedefine HAVE_EXECINFO_H
#cmakedefine HAVE_CXXAPI_H
#cmakedefine HAVE_MAX_ALIGN_T
#cmakedefine HAVE_STD_MAX_ALIGN_T
#cmakedefine SCP_HAVE_EXECINFO_H
#cmakedefine SCP_HAVE_CXXAPI_H
#cmakedefine SCP_HAVE_MAX_ALIGN_T
#cmakedefine SCP_HAVE_STD_MAX_ALIGN_T
#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE
#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE_ARRAY
#cmakedefine01 HAVE_STD_IS_TRIVIALLY_COPYABLE
#cmakedefine01 IS_64BIT
#cmakedefine01 HAVE_STRCASECMP
#cmakedefine01 HAVE_STRNCASECMP
#cmakedefine01 HAVE__STRICMP
#cmakedefine01 HAVE__STRNICMP
#cmakedefine01 SCP_HAVE_STRCASECMP
#cmakedefine01 SCP_HAVE_STRNCASECMP
#cmakedefine01 SCP_HAVE__STRICMP
#cmakedefine01 SCP_HAVE__STRNICMP
#cmakedefine01 HAVE_STRLWR
#cmakedefine01 SCP_HAVE_STRLWR
#cmakedefine01 HAVE_STRINGS_H
#cmakedefine01 SCP_HAVE_STRINGS_H
#cmakedefine01 HAVE_CHAR32_T
#cmakedefine01 HAVE_UNICODE_CHAR_LITERAL
#cmakedefine01 SCP_HAVE_SNPRINTF
#cmakedefine01 SCP_HAVE__SNPRINTF
#endif // __PLATFORM_CHECKS_H__
-2
View File
@@ -9,8 +9,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -funroll-loops -fsigned-char -Wno-
# Omit "conversion from string literal to 'char *' is deprecated" warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-char-subscripts")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
+11 -5
View File
@@ -7,6 +7,8 @@ MESSAGE(STATUS "Doing configuration specific to clang...")
option(CLANG_ENABLE_LEAK_CHECK "Enable -fsanitize=leak" OFF)
option(CLANG_ENABLE_ADDRESS_SANITIZER "Enable -fsanitize=address" OFF)
option(CLANG_USE_LIBCXX "Use libc++" OFF)
# These are the default values
set(C_BASE_FLAGS "-march=native -pipe")
set(CXX_BASE_FLAGS "-march=native -pipe")
@@ -19,6 +21,10 @@ if(DEFINED ENV{CFLAGS})
set(C_BASE_FLAGS $ENV{CFLAGS})
endif()
if (CLANG_USE_LIBCXX)
set(CXX_BASE_FLAGS "${CXX_BASE_FLAGS} -stdlib=libc++")
endif()
# Initialize with an empty string to make sure we always get a clean start
set(COMPILER_FLAGS "")
@@ -66,21 +72,17 @@ set(COMPILER_FLAGS "${COMPILER_FLAGS} ${SANITIZE_FLAGS}")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wformat-security")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-function")
# Dear Clang, please tell us if a function does not return a value since that part of the standard is stupid!
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wreturn-type")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-char-subscripts")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-parameter")
check_cxx_compiler_flag(-Wshift-negative-value SUPPORTS_SHIFT_NEGATIVE_VALUE)
if(SUPPORTS_SHIFT_NEGATIVE_VALUE)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-shift-negative-value")
endif()
set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable")
set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable -Wno-unused-parameter")
set(COMPILER_FLAGS_DEBUG "-O0 -g -Wshadow")
@@ -97,6 +99,10 @@ set(CMAKE_C_FLAGS_DEBUG ${COMPILER_FLAGS_DEBUG})
set(CMAKE_EXE_LINKER_FLAGS "")
if (CLANG_USE_LIBCXX)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
endif()
if (SANITIZE_FLAGS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZE_FLAGS}")
endif()
+13 -5
View File
@@ -78,16 +78,23 @@ set(COMPILER_FLAGS "${COMPILER_FLAGS} ${SANITIZE_FLAGS}")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wformat-security")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-function")
# Dear GCC, please tell us if a function does not return a value since that part of the standard is stupid!
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wreturn-type")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-deprecated -Wno-char-subscripts")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-parameter")
# These two warnings cause a lot of false-positives in the FSO code base
check_cxx_compiler_flag(-Wstringop-truncation SUPPORTS_STRINGOP_TRUNCATION)
if(SUPPORTS_STRINGOP_TRUNCATION)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-stringop-truncation")
endif()
set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-empty-body -Wno-clobbered")
check_cxx_compiler_flag(-Wstringop-overflow SUPPORTS_STRINGOP_OVERFLOW)
if(SUPPORTS_STRINGOP_TRUNCATION)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-stringop-overflow")
endif()
set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-empty-body -Wno-clobbered -Wno-unused-parameter")
set(COMPILER_FLAGS_DEBUG "-O0 -g -Wshadow")
@@ -105,6 +112,7 @@ set(CMAKE_EXE_LINKER_FLAGS "")
IF (MINGW)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++ -Wl,--enable-auto-import")
target_compile_definitions(compiler INTERFACE __USE_MINGW_ANSI_STDIO=1)
ENDIF(MINGW)
if (SANITIZE_FLAGS)
@@ -131,4 +139,4 @@ if (FSO_FATAL_WARNINGS)
endif()
# Always define this to make sure that the fixed width format macros are available
target_compile_definitions(compiler INTERFACE __STDC_FORMAT_MACROS)
target_compile_definitions(compiler INTERFACE __STDC_FORMAT_MACROS=1)
+11 -10
View File
@@ -36,21 +36,24 @@ set(WARNING_FLAGS
/wd4592 # "symbol will be dynamically initialized" is being generated by a compiler bug, see https://stackoverflow.com/a/34027257 for an explanation - m!m
$<$<CONFIG:Release>:/wd4101> # In release mode there are unreferenced variables because debug needs them
/wd4995 # "'vsprintf': name was marked as #pragma deprecated" is being caused by our custom definition of vsprintf. I have no idea what causes this or how to fix it - m!m
/wd4723 # "potential divide by 0" is caused by some code that definitely will not divide by zero - m!m
/wd4121 # "alignment of a member was sensitive to packing" happens in a Windows header - m!m
)
target_compile_options(compiler INTERFACE ${WARNING_FLAGS})
# Base
set(CMAKE_C_FLAGS "/MP /GS- /analyze- /Zc:wchar_t /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo /Zm200")
set(CMAKE_CXX_FLAGS "/MP /GS- /analyze- /Zc:wchar_t /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo /Zm200")
set(CMAKE_C_FLAGS "/MP /GS- /analyze- /Zc:wchar_t /errorReport:prompt /Zc:forScope /Gd /EHsc /nologo /Zm200")
set(CMAKE_CXX_FLAGS "/MP /GS- /analyze- /Zc:wchar_t /errorReport:prompt /Zc:forScope /Gd /EHsc /nologo /Zm200")
set(CMAKE_EXE_LINKER_FLAGS "/MANIFEST /DYNAMICBASE:NO /SAFESEH:NO /ERRORREPORT:PROMPT /NOLOGO")
set(CMAKE_STATIC_LINKER_FLAGS "")
# Release
set(CMAKE_C_FLAGS_RELEASE "/GL /W2 /Gy- /Ox /Ot /Ob2 /fp:precise /GF /Oy /Oi /Zi /W3")
set(CMAKE_CXX_FLAGS_RELEASE "/GL /W2 /Gy- /Ox /Ot /Ob2 /fp:precise /GF /Oy /Oi /Zi /W3")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/OPT:REF /LTCG /INCREMENTAL:NO")
set(CMAKE_C_FLAGS_RELEASE "/GL /Gy- /Ox /Ot /Ob2 /fp:precise /GF /Oy /Oi /Zi /W3")
set(CMAKE_CXX_FLAGS_RELEASE "/GL /Gy- /Ox /Ot /Ob2 /fp:precise /GF /Oy /Oi /Zi /W3")
# /DEBUG:FULL so that we get PDBs which is needed for debugging crashdumps
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/OPT:REF /LTCG /INCREMENTAL:NO /DEBUG:FULL")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "/LTCG")
globally_enable_extra_compiler_warnings()
@@ -62,8 +65,6 @@ if (MSVC_RELEASE_DEBUGGING)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zo")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zo")
endif()
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG")
endif()
IF(MSVC_USE_RUNTIME_DLL)
@@ -135,9 +136,9 @@ else()
ENDIF()
endif()
target_compile_definitions(compiler INTERFACE _CRT_SECURE_NO_DEPRECATE
_CRT_SECURE_NO_WARNINGS _SECURE_SCL=0 NOMINMAX "$<$<CONFIG:FastDebug>:_ITERATOR_DEBUG_LEVEL=0>")
target_compile_definitions(compiler INTERFACE _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _SECURE_SCL=0 NOMINMAX
"$<$<CONFIG:FastDebug>:_ITERATOR_DEBUG_LEVEL=0>" _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
if (FSO_FATAL_WARNINGS)
# Make warnings fatal if the right variable is set
target_compile_options(compiler INTERFACE "/WX")
+15 -3
View File
@@ -141,10 +141,12 @@ macro(set_if_not_defined VAR VALUE)
endmacro(set_if_not_defined)
macro(configure_cotire target)
# Disable unity build as it doesn't work well for us
set_target_properties(${target} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
if(ENABLE_COTIRE)
# Disable unity build as it doesn't work well for us
set_target_properties(${target} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
cotire(${target})
cotire(${target})
endif()
endmacro(configure_cotire)
macro(add_target_copy_files)
@@ -223,3 +225,13 @@ function(list_target_dependencies _target _out_var)
list(REMOVE_DUPLICATES out_list)
set(${_out_var} ${out_list} PARENT_SCOPE)
endfunction(list_target_dependencies)
macro(add_file_folder FOLDER_NAME)
string(MAKE_C_IDENTIFIER "${FOLDER_NAME}" VARIABLE_NAME)
set(files_${VARIABLE_NAME} ${files_${VARIABLE_NAME}} ${ARGN})
string(REPLACE "/" "\\" FIXED_FOLDER_FILE "${FOLDER_NAME}")
source_group("${FIXED_FOLDER_FILE}" FILES ${ARGN})
set(source_files ${source_files} ${ARGN})
endmacro(add_file_folder)
+4 -4
View File
@@ -6,9 +6,9 @@ if (EXISTS "${PROJECT_SOURCE_DIR}/version_override.cmake")
include("${PROJECT_SOURCE_DIR}/version_override.cmake")
endif()
set_if_not_defined(FSO_VERSION_MAJOR 3)
set_if_not_defined(FSO_VERSION_MINOR 8)
set_if_not_defined(FSO_VERSION_BUILD 1)
set_if_not_defined(FSO_VERSION_MAJOR 20)
set_if_not_defined(FSO_VERSION_MINOR 1)
set_if_not_defined(FSO_VERSION_BUILD 0)
# A numeric revision e.g. the CI build number
set_if_not_defined(FSO_VERSION_REVISION 0)
@@ -49,4 +49,4 @@ IF (NOT "${FSO_BUILD_POSTFIX}" STREQUAL "")
ENDIF()
set(CONFIG_POSTFIX "$<$<CONFIG:Release>:>$<$<CONFIG:Debug>:-DEBUG>$<$<CONFIG:FastDebug>:-FASTDBG>")
set(FSO_BINARY_SUFFIX "${FSO_BINARY_SUFFIX}${CONFIG_POSTFIX}")
set(FSO_BINARY_SUFFIX "${FSO_BINARY_SUFFIX}${CONFIG_POSTFIX}")
+35 -3
View File
@@ -3,7 +3,7 @@ INCLUDE(source_groups.cmake)
INCLUDE(voice_rec.cmake)
ADD_LIBRARY(code STATIC ${file_root} ${VOICE_REC_FILES})
ADD_LIBRARY(code STATIC ${source_files} ${VOICE_REC_FILES})
target_compile_features(code PUBLIC ${REQUIRED_CXX_FEATURES})
@@ -28,7 +28,9 @@ TARGET_LINK_LIBRARIES(code PUBLIC ${JPEG_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC sdl2)
TARGET_LINK_LIBRARIES(code PUBLIC ffmpeg)
if (FSO_BUILD_WITH_FFMPEG)
TARGET_LINK_LIBRARIES(code PUBLIC ffmpeg)
endif()
TARGET_LINK_LIBRARIES(code PUBLIC utfcpp)
@@ -37,6 +39,14 @@ TARGET_LINK_LIBRARIES(code PUBLIC compiler)
target_link_libraries(code PUBLIC md5)
target_link_libraries(code PUBLIC discord-rpc)
target_link_libraries(code PUBLIC libRocket)
target_link_libraries(code PUBLIC pcp)
target_link_libraries(code PUBLIC vulkan-hpp)
enable_clang_tidy(code)
IF (FSO_USE_SPEECH)
@@ -57,7 +67,29 @@ IF(FSO_BUILD_TOOLS)
ADD_SUBDIRECTORY(cfileextractor)
ENDIF(FSO_BUILD_TOOLS)
set_target_properties(code PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "prefix_header.h")
if (ENABLE_COTIRE)
set_target_properties(code PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h")
else()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-include${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:/FI ${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-include${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-include${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
ELSE()
MESSAGE("Unknown compiler for global includes. This will probably break the build.")
ENDIF()
endif()
if (FSO_RELEASE_LOGGING)
target_compile_definitions(code PUBLIC SCP_RELEASE_LOGGING)
endif()
if (FSO_BUILD_WITH_FFMPEG)
target_compile_definitions(code PUBLIC WITH_FFMPEG)
endif()
include(util)
configure_cotire(code)
+15 -13
View File
@@ -18,8 +18,7 @@
#include "ship/ship.h"
int Total_goal_target_names = 0;
char Goal_target_names[MAX_GOAL_TARGET_NAMES][NAME_LENGTH];
SCP_vector<char *> Goal_target_names;
ai_info Ai_info[MAX_AI_INFO];
ai_info *Player_ai;
@@ -82,22 +81,25 @@ void set_wingnum(int objnum, int wingnum)
Ai_info[ai_index].wing = wingnum;
}
char *ai_get_goal_target_name(const char *name, int *index)
const char *ai_get_goal_target_name(const char *name, int *index)
{
Assert(name != NULL);
Assert(index != NULL);
int i;
Assertion(name != nullptr && index != nullptr, "Arguments cannot be null!");
for (i=0; i < Total_goal_target_names; i++)
for (int i = 0; i < static_cast<int>(Goal_target_names.size()); ++i) {
if (!stricmp(name, Goal_target_names[i])) {
*index = i;
return Goal_target_names[i];
}
}
Assert(Total_goal_target_names < MAX_GOAL_TARGET_NAMES);
Assertion(strlen(name) <= NAME_LENGTH - 1, "Goal target name %s is too long. Needs to be 31 characters or less.", name);
i = Total_goal_target_names++;
strcpy_s(Goal_target_names[i], name);
*index = i;
return Goal_target_names[i];
*index = static_cast<int>(Goal_target_names.size());
Goal_target_names.push_back(vm_strdup(name));
return Goal_target_names[*index];
}
void ai_clear_goal_target_names()
{
for (auto ptr : Goal_target_names)
vm_free(ptr);
Goal_target_names.clear();
}
+9 -17
View File
@@ -83,7 +83,7 @@ typedef struct ai_goal {
fix time; // time at which this goal was issued.
int priority; // how important is this goal -- number 0 - 100
char *target_name; // name of the thing that this goal acts upon
const char *target_name; // name of the thing that this goal acts upon
int target_name_index; // index of goal_target_name in Goal_target_names[][]
waypoint_list *wp_list; // waypoints that this ship might fly.
int target_instance; // instance of thing this ship might be chasing (currently only used for weapons; note, not the same as objnum!)
@@ -93,19 +93,17 @@ typedef struct ai_goal {
// (AIGF_DOCKER_INDEX_VALID and AIGF_DOCKEE_INDEX_VALID tell us to use indexes; otherwise we use names)
// these are the dockpoints used on the docker and dockee ships, not the ships themselves
union {
char *name;
const char *name;
int index;
} docker;
union {
char *name;
const char *name;
int index;
} dockee;
} ai_goal;
#define MAX_GOAL_TARGET_NAMES 100
#define AIM_CHASE 0
#define AIM_EVADE 1
#define AIM_GET_BEHIND 2
@@ -513,8 +511,6 @@ typedef struct {
#define BURST_DURATION 500 // decay time over which Player->damage_this_burst falls from MAX_BURST_DAMAGE to 0
extern int Mission_all_attack; // !0 means all teams attack all teams.
extern int Total_goal_target_names;
extern char Goal_target_names[MAX_GOAL_TARGET_NAMES][NAME_LENGTH];
extern void update_ai_info_for_hit(int hitter_obj, int hit_obj);
extern void ai_frame_all(void);
@@ -556,7 +552,8 @@ void ai_process( object * obj, int ai_index, float frametime );
int get_wingnum(int objnum);
void set_wingnum(int objnum, int wingnum);
char *ai_get_goal_target_name(const char *name, int *index);
const char *ai_get_goal_target_name(const char *name, int *index);
void ai_clear_goal_target_names();
extern void init_ai_system(void);
extern void ai_attack_object(object *attacker, object *attacked, ship_subsys *ssp, int ship_info_index = -1);
@@ -567,9 +564,9 @@ extern void ai_dock_with_object(object *docker, int docker_index, object *dockee
extern void ai_stay_still(object *still_objp, vec3d *view_pos);
extern void ai_do_default_behavior(object *obj);
extern void ai_start_waypoints(object *objp, waypoint_list *wp_list, int wp_flags);
extern void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_quadrant, vec3d *hit_normal);
extern void ai_ship_destroy(int shipnum, Ship::Exit_Flags method);
extern void ai_turn_towards_vector(vec3d *dest, object *objp, float frametime, float turn_time, vec3d *slide_vec, vec3d *rel_pos, float bank_override, int flags, vec3d *rvec = NULL, int sexp_flags = 0);
extern void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hit_normal);
extern void ai_ship_destroy(int shipnum);
extern void ai_turn_towards_vector(vec3d *dest, object *objp, float turn_time, vec3d *slide_vec, vec3d *rel_pos, float bank_override, int flags, vec3d *rvec = nullptr, int sexp_flags = 0);
extern void init_ai_object(int objnum);
extern void ai_init(void); // Call this one to parse ai.tbl.
extern void ai_level_init(void); // Call before each level to reset AI
@@ -587,13 +584,10 @@ extern void get_absolute_wing_pos_autopilot( vec3d *result_pos, object *leader_o
// Interface from goals code to AI. Set ship to guard. *objp guards *other_objp
extern void ai_set_guard_object(object *objp, object *other_objp);
extern void ai_set_evade_object(object *objp, object *other_objp);
extern void ai_set_guard_wing(object *objp, int wingnum);
extern void ai_warp_out(object *objp, vec3d *vp);
extern void ai_attack_wing(object *attacker, int wingnum);
extern void ai_deathroll_start(object *ship_obj);
extern void ai_fly_in_formation(int wing_num); // Force wing to fly in formation.
extern void ai_disband_formation(int wing_num); // Force wing to disband formation flying.
extern int set_target_objnum(ai_info *aip, int objnum);
extern void ai_form_on_wing(object *objp, object *goal_objp);
extern void ai_do_stay_near(object *objp, object *other_obj, float dist);
@@ -622,7 +616,7 @@ extern float ai_path();
extern void evade_weapon();
extern int might_collide_with_ship(object *obj1, object *obj2, float dot_to_enemy, float dist_to_enemy, float duration);
extern int ai_fire_primary_weapon(object *objp); //changed to return weather it fired-Bobboau
extern int ai_fire_secondary_weapon(object *objp, int priority1 = -1, int priority2 = -1);
extern int ai_fire_secondary_weapon(object *objp);
extern float ai_get_weapon_dist(ship_weapon *swp);
extern void turn_towards_point(object *objp, vec3d *point, vec3d *slide_vec, float bank_override);
extern int ai_maybe_fire_afterburner(object *objp, ai_info *aip);
@@ -646,8 +640,6 @@ extern void ai_do_objects_repairing_stuff( object *repaired_obj, object *repair_
// Move to a position relative to a dock bay using thrusters.
extern float dock_orient_and_approach(object *docker_objp, int docker_index, object *dockee_objp, int dockee_index, int dock_mode, rotating_dockpoint_info *rdinfo = NULL);
extern int find_danger_weapon(object *sobjp, float dtime, float *atime, float dot_threshhold);
void ai_set_mode_warp_out(object *objp, ai_info *aip);
// prototyped by Goober5000
+16 -4
View File
@@ -51,14 +51,19 @@ namespace AI {
};
FLAG_LIST(Maneuver_Override_Flags) {
Full, // Full sexp control
Full_rot, // full sexp control over pitch/bank/heading rotation
Roll, // Sexp forced roll maneuver
Pitch, // Sexp forced pitch change
Heading, // Sexp forced heading change
Full_lat, // full control over up/side/forward movement
Up, // vertical movement
Sideways, // horizontal movement
Forward, // forward movement
Up, // Sexp forced vertical movement
Sideways, // Sexp forced horizontal movement
Forward, // Sexp forced forward movement
Dont_bank_when_turning, // maps to CIF_DONT_BANK_WHEN_TURNING
Dont_clamp_max_velocity, // maps to CIF_DONT_CLAMP_MAX_VELOCITY
Instantaneous_acceleration, // maps to CIF_INSTANTANEOUS_ACCELERATION
Never_expire, // don't clear the maneuver when the timestamp is up
NUM_VALUES
};
@@ -79,14 +84,19 @@ namespace AI {
Assist_scoring_scales_with_damage,
Beams_damage_weapons,
Big_ships_can_attack_beam_turrets_on_untargeted_ships,
Check_comms_for_non_player_ships,
Disable_linked_fire_penalty,
Disable_player_secondary_doublefire,
Disable_ai_secondary_doublefire,
Disable_weapon_damage_scaling,
Dont_insert_random_turret_fire_delay,
Fix_ai_class_bug,
Fix_ai_path_order_bug,
Fix_heat_seeker_stealth_bug,
Fix_linked_primary_bug,
Fix_ramming_stationary_targets_bug,
Force_beam_turret_fov,
Free_afterburner_use,
Glide_decay_requires_thrust,
Hack_improve_non_homing_swarm_turret_fire_accuracy,
Huge_turret_weapons_ignore_bombs,
@@ -109,7 +119,9 @@ namespace AI {
Smart_shield_management,
Smart_subsystem_targeting_for_turrets,
Strict_turred_tagged_only_targeting,
Support_dont_add_primaries, //Prevents support ship from equipping new primary as requested in http://scp.indiegames.us/mantis/view.php?id=3198
Turrets_ignore_target_radius,
Use_actual_primary_range,
Use_additive_weapon_velocity,
Use_newtonian_dampening,
Use_only_single_fov_for_turrets,
+34 -6
View File
@@ -7,11 +7,11 @@
#include "globalincs/pstypes.h"
#include "def_files/def_files.h"
#include "ai/ai_profiles.h"
#include "def_files/def_files.h"
#include "globalincs/pstypes.h"
#include "localization/localize.h"
#include "mod_table/mod_table.h"
#include "parse/parselo.h"
#include "ship/ship.h"
#include "weapon/weapon.h"
@@ -357,6 +357,8 @@ void parse_ai_profiles_tbl(const char *filename)
set_flag(profile, "$smart afterburner management:", AI::Profile_Flags::Smart_afterburner_management);
set_flag(profile, "$free afterburner use:", AI::Profile_Flags::Free_afterburner_use);
set_flag(profile, "$allow rapid secondary dumbfire:", AI::Profile_Flags::Allow_rapid_secondary_dumbfire);
set_flag(profile, "$huge turret weapons ignore bombs:", AI::Profile_Flags::Huge_turret_weapons_ignore_bombs);
@@ -369,10 +371,16 @@ void parse_ai_profiles_tbl(const char *filename)
set_flag(profile, "$navigation subsystem governs warpout capability:", AI::Profile_Flags::Navigation_subsys_governs_warp);
set_flag(profile, "$check communications for non-player ships:", AI::Profile_Flags::Check_comms_for_non_player_ships);
set_flag(profile, "$ignore lower bound for minimum speed of docked ship:", AI::Profile_Flags::No_min_dock_speed_cap);
set_flag(profile, "$disable linked fire penalty:", AI::Profile_Flags::Disable_linked_fire_penalty);
set_flag(profile, "$disable player secondary doublefire:", AI::Profile_Flags::Disable_player_secondary_doublefire);
set_flag(profile, "$disable ai secondary doublefire:", AI::Profile_Flags::Disable_ai_secondary_doublefire);
set_flag(profile, "$disable weapon damage scaling:", AI::Profile_Flags::Disable_weapon_damage_scaling);
set_flag(profile, "$use additive weapon velocity:", AI::Profile_Flags::Use_additive_weapon_velocity);
@@ -389,6 +397,8 @@ void parse_ai_profiles_tbl(const char *filename)
set_flag(profile, "$fix linked primary weapon decision bug:", AI::Profile_Flags::Fix_linked_primary_bug);
set_flag(profile, "$fix ramming stationary targets bug:", AI::Profile_Flags::Fix_ramming_stationary_targets_bug);
set_flag(profile, "$prevent turrets targeting too distant bombs:", AI::Profile_Flags::Prevent_targeting_bombs_beyond_range);
set_flag(profile, "$smart subsystem targeting for turrets:", AI::Profile_Flags::Smart_subsystem_targeting_for_turrets);
@@ -433,6 +443,8 @@ void parse_ai_profiles_tbl(const char *filename)
set_flag(profile, "$ai guards specific ship in wing:", AI::Profile_Flags::Ai_guards_specific_ship_in_wing);
set_flag(profile, "$support don't add primaries:", AI::Profile_Flags::Support_dont_add_primaries);
profile->ai_path_mode = AI_PATH_MODE_NORMAL;
if (optional_string("$ai path mode:"))
{
@@ -458,6 +470,8 @@ void parse_ai_profiles_tbl(const char *filename)
set_flag(profile, "$ai can slow down when attacking big ships:", AI::Profile_Flags::Ai_can_slow_down_attacking_big_ships);
set_flag(profile, "$use actual primary range:", AI::Profile_Flags::Use_actual_primary_range);
profile->bay_arrive_speed_mult = 1.0f;
profile->bay_depart_speed_mult = 1.0f;
if (optional_string("$bay arrive speed multiplier:")) {
@@ -511,10 +525,6 @@ void parse_ai_profiles_tbl(const char *filename)
mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", (filename) ? filename : "<default ai_profiles.tbl>", e.what()));
return;
}
// add tbl/tbm to multiplayer validation list
extern void fs2netd_add_table_validation(const char *tblname);
fs2netd_add_table_validation(filename);
}
void ai_profiles_init()
@@ -622,4 +632,22 @@ void ai_profile_t::reset()
for (int i = 0; i <= MAX_DETAIL_LEVEL; ++i) {
detail_distance_mult[i] = 0;
}
// via Github #2332, enable bugfixes if we are targeting version 20 and up
if (mod_supports_version(20, 0, 0)) {
flags.set(AI::Profile_Flags::Huge_turret_weapons_ignore_bombs);
flags.set(AI::Profile_Flags::Fix_linked_primary_bug);
flags.set(AI::Profile_Flags::Prevent_targeting_bombs_beyond_range);
flags.set(AI::Profile_Flags::Fix_heat_seeker_stealth_bug);
flags.set(AI::Profile_Flags::Allow_vertical_dodge);
flags.set(AI::Profile_Flags::Fix_ai_class_bug);
flags.set(AI::Profile_Flags::Ai_guards_specific_ship_in_wing);
flags.set(AI::Profile_Flags::Fix_ai_path_order_bug);
flags.set(AI::Profile_Flags::Aspect_invulnerability_fix);
flags.set(AI::Profile_Flags::Use_actual_primary_range);
}
// this flag has been enabled ever since 3.7.2
if (mod_supports_version(3, 7, 2)) {
flags.set(AI::Profile_Flags::Fix_ramming_stationary_targets_bug);
}
}
+20 -26
View File
@@ -64,10 +64,11 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
void ai_big_avoid_ship();
int ai_big_maybe_follow_subsys_path(int do_dot_check=1);
void ai_big_strafe_position();
static int ai_big_strafe_maybe_retreat(const vec3d *target_pos);
extern int model_which_octant_distant_many( vec3d *pnt, int model_num,matrix *model_orient, vec3d * model_pos, polymodel **pm, int *octs);
extern void compute_desired_rvec(vec3d *rvec, vec3d *goal_pos, vec3d *cur_pos);
extern void big_ship_collide_recover_start(object *objp, object *big_objp, vec3d *collide_pos, vec3d *collision_normal);
extern void big_ship_collide_recover_start(object *objp, object *big_objp, vec3d *collision_normal);
// Called by ai_big_pick_attack_point.
@@ -631,7 +632,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
else
rvec = NULL;
ai_turn_towards_vector(enemy_pos, Pl_objp, flFrametime, sip->srotation_time, NULL, rel_pos, 0.0f, 0, rvec);
ai_turn_towards_vector(enemy_pos, Pl_objp, sip->srotation_time, nullptr, rel_pos, 0.0f, 0, rvec);
// calc range of primary weapon
weapon_travel_dist = ai_get_weapon_dist(&Ships[Pl_objp->instance].weapons);
@@ -641,7 +642,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
accelerate_ship(aip, 1.0f);
ship *shipp = &Ships[Pl_objp->instance];
if ((aip->ai_flags[AI::AI_Flags::Free_afterburner_use]) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (dot_to_enemy > 0.75f)) {
if ((aip->ai_flags[AI::AI_Flags::Free_afterburner_use] || aip->ai_profile_flags[AI::Profile_Flags::Free_afterburner_use]) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (dot_to_enemy > 0.75f)) {
if (ai_maybe_fire_afterburner(Pl_objp, aip)) {
afterburners_start(Pl_objp);
aip->afterburner_stop_time = Missiontime + 3*F1_0;
@@ -683,7 +684,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
accelerate_ship(aip, accel);
ship *shipp = &Ships[Pl_objp->instance];
if ((aip->ai_flags[AI::AI_Flags::Free_afterburner_use]) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (accel > 0.95f)) {
if ((aip->ai_flags[AI::AI_Flags::Free_afterburner_use] || aip->ai_profile_flags[AI::Profile_Flags::Free_afterburner_use]) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (accel > 0.95f)) {
if (ai_maybe_fire_afterburner(Pl_objp, aip)) {
afterburners_start(Pl_objp);
aip->afterburner_stop_time = Missiontime + 3*F1_0;
@@ -707,14 +708,14 @@ extern float set_secondary_fire_delay(ai_info *aip, ship *shipp, weapon_info *sw
extern void ai_choose_secondary_weapon(object *objp, ai_info *aip, object *en_objp);
extern int maybe_avoid_big_ship(object *objp, object *ignore_objp, ai_info *aip, vec3d *goal_point, float delta_time);
extern void maybe_cheat_fire_synaptic(object *objp, ai_info *aip);
extern void maybe_cheat_fire_synaptic(object *objp);
// Determine if Pl_objp should fire weapons at current target, based on input parameters
//
// dist_to_enemy => distance (in m) to attack point on current target
// dot_to_enemy => dot product between fvec of Pl_objp and vector from Pl_objp to attack point
//
void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy, vec3d *firing_pos, vec3d *enemy_pos, vec3d *enemy_vel)
static void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy)
{
ai_info *aip;
ship_weapon *swp;
@@ -845,8 +846,6 @@ void ai_big_switch_to_chase_mode(ai_info *aip)
aip->submode_start_time = Missiontime;
}
extern int ai_big_strafe_maybe_retreat(float dist, vec3d *target_pos);
// Make object Pl_objp chase object En_objp, which is a big ship, not a small ship.
void ai_big_chase()
{
@@ -859,7 +858,7 @@ void ai_big_chase()
Assert(aip->mode == AIM_CHASE);
maybe_cheat_fire_synaptic(Pl_objp, aip);
maybe_cheat_fire_synaptic(Pl_objp);
ai_set_positions(Pl_objp, En_objp, aip, &player_pos, &enemy_pos);
@@ -882,7 +881,7 @@ void ai_big_chase()
dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.vec.fvec);
if (aip->ai_flags[AI::AI_Flags::Target_collision]) {
if ( ai_big_strafe_maybe_retreat(dist_to_enemy, &enemy_pos) ) {
if ( ai_big_strafe_maybe_retreat(&enemy_pos) ) {
aip->mode = AIM_STRAFE;
aip->submode_parm0 = Missiontime; // use parm0 as time strafe mode entered (i.e. MODE start time)
aip->submode = AIS_STRAFE_AVOID;
@@ -1045,7 +1044,7 @@ void ai_big_chase()
if ((dist_normal_to_enemy < ATTACK_COLLIDE_AVOID_DIST + speed_dist) || (time_to_enemy < ATTACK_COLLIDE_AVOID_TIME) ) {
// get away, simulate crsh recovery (don't use avoid)
// accelerate_ship(aip, -1.0f);
big_ship_collide_recover_start(Pl_objp, En_objp, &Pl_objp->pos, NULL);
big_ship_collide_recover_start(Pl_objp, En_objp, nullptr);
// aip->submode = SM_AVOID;
// aip->submode_start_time = Missiontime;
} else if ((dist_normal_to_enemy < ATTACK_COLLIDE_SLOW_DIST) || (time_to_enemy < ATTACK_COLLIDE_SLOW_TIME) ) {
@@ -1144,7 +1143,7 @@ void ai_big_chase()
// TODO: investigate why ships fire (and aren't close to hitting ship) when following a path near
// a big ship
if (aip->mode != AIM_EVADE && aip->path_start == -1 ) {
ai_big_maybe_fire_weapons(dist_to_enemy, dot_to_enemy, &player_pos, &predicted_enemy_pos, &En_objp->phys_info.vel);
ai_big_maybe_fire_weapons(dist_to_enemy, dot_to_enemy);
} else {
if (flFrametime < 1.0f)
aip->time_enemy_in_range *= (1.0f - flFrametime);
@@ -1153,11 +1152,6 @@ void ai_big_chase()
}
}
void ai_big_ship(object *objp)
{
// do nothing
}
// all three parms are output parameters
// Enemy object is En_objp
// pos => world pos of attack point
@@ -1228,7 +1222,7 @@ void ai_big_attack_get_data(vec3d *enemy_pos, float *dist_to_enemy, float *dot_t
// check to see if Pl_objp has gotten too close to attacking point.. if so, break off by entering
// AIS_STRAFE_RETREAT
int ai_big_strafe_maybe_retreat(float dist, vec3d *target_pos)
static int ai_big_strafe_maybe_retreat(const vec3d *target_pos)
{
ai_info *aip;
aip = &Ai_info[Ships[Pl_objp->instance].ai_index];
@@ -1258,7 +1252,7 @@ int ai_big_strafe_maybe_retreat(float dist, vec3d *target_pos)
if (aip->ai_flags[AI::AI_Flags::Target_collision]) {
// use standard collision resolution
aip->ai_flags.remove(AI::AI_Flags::Target_collision);
big_ship_collide_recover_start(Pl_objp, En_objp, &Pl_objp->pos, NULL);
big_ship_collide_recover_start(Pl_objp, En_objp, nullptr);
} else {
// too close for comfort so fly to box point + 300
aip->submode = AIS_STRAFE_RETREAT1;
@@ -1298,12 +1292,12 @@ void ai_big_strafe_attack()
}
ai_big_attack_get_data(&target_pos, &target_dist, &target_dot);
if ( ai_big_strafe_maybe_retreat(target_dist, &target_pos) )
if ( ai_big_strafe_maybe_retreat(&target_pos) )
return;
if (aip->ai_flags[AI::AI_Flags::Kamikaze]) {
if (target_dist < 1200.0f) {
ai_turn_towards_vector(&target_pos, Pl_objp, flFrametime, Ship_info[Ships[Pl_objp->instance].ship_info_index].srotation_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&target_pos, Pl_objp, Ship_info[Ships[Pl_objp->instance].ship_info_index].srotation_time, nullptr, nullptr, 0.0f, 0);
accelerate_ship(aip, 1.0f);
if ((target_dist < 400.0f) && ai_maybe_fire_afterburner(Pl_objp, aip)) {
afterburners_start(Pl_objp);
@@ -1347,7 +1341,7 @@ void ai_big_strafe_attack()
}
// maybe fire weapons at target
ai_big_maybe_fire_weapons(target_dist, target_dot, &Pl_objp->pos, &En_objp->pos, &En_objp->phys_info.vel);
ai_big_maybe_fire_weapons(target_dist, target_dot);
turn_towards_point(Pl_objp, &target_pos, NULL, 0.0f);
fix last_hit = Missiontime - aip->last_hit_time;
@@ -1493,7 +1487,7 @@ void ai_big_strafe_glide_attack()
vm_vec_sub2(&target_pos, &En_objp->pos);
turn_towards_point(Pl_objp, &target_pos, NULL, 0.0f);
ai_big_maybe_fire_weapons(target_dist, target_dot, &Pl_objp->pos, &En_objp->pos, &En_objp->phys_info.vel);
ai_big_maybe_fire_weapons(target_dist, target_dot);
}
// if haven't been hit in quite a while, leave strafe mode
@@ -1517,7 +1511,7 @@ void ai_big_strafe_avoid()
mode_time = Missiontime - aip->submode_start_time;
ai_big_attack_get_data(&target_pos, &target_dist, &target_dot);
if ( ai_big_strafe_maybe_retreat(target_dist, &target_pos) )
if ( ai_big_strafe_maybe_retreat(&target_pos) )
return;
if ( mode_time > fl2f(0.5)) {
@@ -1704,7 +1698,7 @@ void ai_big_strafe()
//
// Check if weapon_objnum was fired by Pl_objp's target, and whether Pl_objp's target is a big ship, if
// so, enter AIM_STRAFE
int ai_big_maybe_enter_strafe_mode(object *pl_objp, int weapon_objnum, int consider_target_only)
int ai_big_maybe_enter_strafe_mode(const object *pl_objp, int weapon_objnum)
{
ai_info *aip;
ship_info *sip;
@@ -1778,7 +1772,7 @@ int ai_big_maybe_enter_strafe_mode(object *pl_objp, int weapon_objnum, int consi
// Consider attacking a turret, if a turret actually fired the weapon
// input: ship_objp => ship that will attack the turret
// weapon_objp =>
void ai_big_strafe_maybe_attack_turret(object *ship_objp, object *weapon_objp)
void ai_big_strafe_maybe_attack_turret(const object *ship_objp, const object *weapon_objp)
{
ai_info *aip;
object *parent_objp;
+2 -3
View File
@@ -17,14 +17,13 @@ struct ai_info;
struct vec3d;
class ship_subsys;
void ai_big_ship(object *objp);
void ai_big_chase();
void ai_big_subsys_path_cleanup(ai_info *aip);
// strafe functions
void ai_big_strafe();
int ai_big_maybe_enter_strafe_mode(object *objp, int weapon_objnum, int consider_target_only=0);
void ai_big_strafe_maybe_attack_turret(object *ship_objp, object *weapon_objp);
int ai_big_maybe_enter_strafe_mode(const object *objp, int weapon_objnum);
void ai_big_strafe_maybe_attack_turret(const object *ship_objp, const object *weapon_objp);
void ai_big_pick_attack_point(object *objp, object *attacker_objp, vec3d *attack_point, float fov=1.0f);
void ai_big_pick_attack_point_turret(object *objp, ship_subsys *ssp, vec3d *gpos, vec3d *gvec, vec3d *attack_point, float weapon_travel_dist, float fov=1.0f);
+239 -279
View File
File diff suppressed because it is too large. Load diff
+105 -70
View File
@@ -21,6 +21,7 @@
#include "object/waypoint.h"
#include "parse/sexp.h"
#include "playerman/player.h"
#include "scripting/scripting.h"
#include "ship/ship.h"
#include "weapon/weapon.h"
@@ -62,31 +63,32 @@ char Ai_dock_names[MAX_AI_DOCK_NAMES][NAME_LENGTH];
// Used in objecttypes.tbl to define custom ship types
ai_goal_list Ai_goal_names[] =
{
{ "Attack ship", AI_GOAL_CHASE, 0 },
{ "Dock", AI_GOAL_DOCK, 0 },
{ "Waypoints", AI_GOAL_WAYPOINTS, 0 },
{ "Waypoints once", AI_GOAL_WAYPOINTS_ONCE, 0 },
{ "Depart", AI_GOAL_WARP, 0 },
{ "Attack subsys", AI_GOAL_DESTROY_SUBSYSTEM, 0 },
{ "Form on wing", AI_GOAL_FORM_ON_WING, 0 },
{ "Undock", AI_GOAL_UNDOCK, 0 },
{ "Attack wing", AI_GOAL_CHASE_WING, 0 },
{ "Guard ship", AI_GOAL_GUARD, 0 },
{ "Disable ship", AI_GOAL_DISABLE_SHIP, 0 },
{ "Disarm ship", AI_GOAL_DISARM_SHIP, 0 },
{ "Attack any", AI_GOAL_CHASE_ANY, 0 },
{ "Ignore ship", AI_GOAL_IGNORE, 0 },
{ "Ignore ship (new)", AI_GOAL_IGNORE_NEW, 0 },
{ "Guard wing", AI_GOAL_GUARD_WING, 0 },
{ "Evade ship", AI_GOAL_EVADE_SHIP, 0 },
{ "Stay near ship", AI_GOAL_STAY_NEAR_SHIP, 0 },
{ "keep safe dist", AI_GOAL_KEEP_SAFE_DISTANCE, 0 },
{ "Rearm ship", AI_GOAL_REARM_REPAIR, 0 },
{ "Stay still", AI_GOAL_STAY_STILL, 0 },
{ "Play dead", AI_GOAL_PLAY_DEAD, 0 },
{ "Attack weapon", AI_GOAL_CHASE_WEAPON, 0 },
{ "Fly to ship", AI_GOAL_FLY_TO_SHIP, 0 },
{ "Attack ship class", AI_GOAL_CHASE_SHIP_CLASS, 0 },
{ "Attack ship", AI_GOAL_CHASE, 0 },
{ "Dock", AI_GOAL_DOCK, 0 },
{ "Waypoints", AI_GOAL_WAYPOINTS, 0 },
{ "Waypoints once", AI_GOAL_WAYPOINTS_ONCE, 0 },
{ "Depart", AI_GOAL_WARP, 0 },
{ "Attack subsys", AI_GOAL_DESTROY_SUBSYSTEM, 0 },
{ "Form on wing", AI_GOAL_FORM_ON_WING, 0 },
{ "Undock", AI_GOAL_UNDOCK, 0 },
{ "Attack wing", AI_GOAL_CHASE_WING, 0 },
{ "Guard ship", AI_GOAL_GUARD, 0 },
{ "Disable ship", AI_GOAL_DISABLE_SHIP, 0 },
{ "Disarm ship", AI_GOAL_DISARM_SHIP, 0 },
{ "Attack any", AI_GOAL_CHASE_ANY, 0 },
{ "Ignore ship", AI_GOAL_IGNORE, 0 },
{ "Ignore ship (new)", AI_GOAL_IGNORE_NEW, 0 },
{ "Guard wing", AI_GOAL_GUARD_WING, 0 },
{ "Evade ship", AI_GOAL_EVADE_SHIP, 0 },
{ "Stay near ship", AI_GOAL_STAY_NEAR_SHIP, 0 },
{ "keep safe dist", AI_GOAL_KEEP_SAFE_DISTANCE, 0 },
{ "Rearm ship", AI_GOAL_REARM_REPAIR, 0 },
{ "Stay still", AI_GOAL_STAY_STILL, 0 },
{ "Play dead", AI_GOAL_PLAY_DEAD, 0 },
{ "Play dead (persistent)", AI_GOAL_PLAY_DEAD_PERSISTENT, 0 },
{ "Attack weapon", AI_GOAL_CHASE_WEAPON, 0 },
{ "Fly to ship", AI_GOAL_FLY_TO_SHIP, 0 },
{ "Attack ship class", AI_GOAL_CHASE_SHIP_CLASS, 0 },
};
int Num_ai_goals = sizeof(Ai_goal_names) / sizeof(ai_goal_list);
@@ -125,7 +127,7 @@ const char *Ai_goal_text(int goal)
case AI_GOAL_REARM_REPAIR:
return XSTR( "rearm ", 484);
case AI_GOAL_FLY_TO_SHIP:
return XSTR( "rendezvous with ", -1);
return XSTR( "rendezvous with ", 1597);
}
// Avoid compiler warning
@@ -267,6 +269,12 @@ void ai_clear_ship_goals( ai_info *aip )
{
ai_do_default_behavior( &Objects[Ships[aip->shipnum].objnum] );
}
// add scripting hook for 'On Goals Cleared' --wookieejedi
Script_system.SetHookObject("Ship", &Objects[Ships[aip->shipnum].objnum]);
Script_system.RunCondition(CHA_ONGOALSCLEARED);
Script_system.RemHookVars(1, "Ship");
}
void ai_clear_wing_goals( int wingnum )
@@ -302,7 +310,7 @@ void ai_clear_wing_goals( int wingnum )
void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp )
{
int mode, submode, priority, i;
char *name;
const char *name;
ai_goal *aigp;
wing *wingp;
@@ -380,7 +388,7 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai
{
int i, j;
ai_goal *purge_goal;
char *name;
const char *name;
int mode, ship_index, wingnum;
// get locals for easer access
@@ -414,7 +422,7 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai
if ( purge_ai_mode == AI_GOAL_CHASE_SHIP_CLASS ) {
// if the target of the purge goal is the same class of ship we are concerned about, then we have a match;
// if it is not, then we can continue (see standard ship check below)
if ( stricmp(purge_goal->target_name, Ship_info[Ships[ship_index].ship_info_index].name) )
if ( stricmp(purge_goal->target_name, Ship_info[Ships[ship_index].ship_info_index].name) != 0 )
continue;
}
// standard goals operating on either wings or ships
@@ -426,7 +434,7 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai
// don't match, we can continue; if the wing is valid, don't process if the wing numbers
// are different.
if ( purge_wing == -1 ) {
if ( stricmp(purge_goal->target_name, name ) )
if ( stricmp(purge_goal->target_name, name ) != 0 )
continue;
} else if ( purge_wing != wingnum )
continue;
@@ -732,6 +740,12 @@ void ai_add_goal_sub_scripting(int type, int mode, int submode, int priority, ch
aigp->target_signature = Objects[Weapons[submode].objnum].signature;
}
if ( mode == AI_GOAL_WAYPOINTS_ONCE || mode == AI_GOAL_WAYPOINTS ) {
// should be the same as setting via sexp, see ai_add_goal_sub_sexp
// set to null so the AI code can setup the new waypoint list, see ai_mission_goal_achievable
aigp->wp_list = nullptr;
}
if ( target_name != NULL )
aigp->target_name = ai_get_goal_target_name( target_name, &aigp->target_name_index );
else
@@ -937,6 +951,11 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name )
aigp->ai_mode = AI_GOAL_PLAY_DEAD;
break;
case OP_AI_PLAY_DEAD_PERSISTENT:
aigp->priority = atoi( CTEXT(CDR(node)) );
aigp->ai_mode = AI_GOAL_PLAY_DEAD_PERSISTENT;
break;
case OP_AI_KEEP_SAFE_DISTANCE:
aigp->priority = atoi( CTEXT(CDR(node)) );
aigp->ai_mode = AI_GOAL_KEEP_SAFE_DISTANCE;
@@ -1126,6 +1145,10 @@ int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp )
goalmode = AI_GOAL_PLAY_DEAD;
priority = ( CDR(node) >= 0 ) ? atoi( CTEXT( CDR( node ) ) ) : -1;
break;
case OP_AI_PLAY_DEAD_PERSISTENT:
goalmode = AI_GOAL_PLAY_DEAD_PERSISTENT;
priority = ( CDR(node) >= 0 ) ? atoi( CTEXT( CDR( node ) ) ) : -1;
break;
case OP_AI_KEEP_SAFE_DISTANCE:
priority = ( CDR(node) >= 0 ) ? atoi( CTEXT( CDR( node ) ) ) : -1;
goalmode = AI_GOAL_KEEP_SAFE_DISTANCE;
@@ -1263,7 +1286,7 @@ void ai_add_wing_goal_sexp(int sexp, int type, int wingnum)
// this name can be a shipname or a wingname)
// docker_point and dockee_point are used for the AI_GOAL_DOCK command to tell two ships where to dock
// immediate means to process this order right away
void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int docker_point, int dockee_point, int immediate )
void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int /*docker_point*/, int /*dockee_point*/, int immediate )
{
int gindex;
ai_goal *aigp;
@@ -1340,25 +1363,6 @@ void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int doc
ai_process_mission_orders( Ships[aip->shipnum].objnum, aip );
}
// function to add an internal goal to a wing. Mike K says that the goal doesn't need to persist
// across waves of the wing so we merely need to add the goal to each ship in the wing. Certain
// goal are simply not valid for wings (like dock, undock). Immediate parameter gets passed to add_ship_goal
// to say whether or not we should process this goal right away
void ai_add_goal_wing_internal( wing *wingp, int goal_type, char *name, int immediate )
{
int i;
// be sure we are not trying to issue dock or undock goals to wings
Assert ( (goal_type != AI_GOAL_DOCK) && (goal_type != AI_GOAL_UNDOCK) );
for (i = 0; i < wingp->current_count; i++) {
int num = wingp->ship_index[i];
if ( num == -1 ) // ship must have been destroyed or departed
continue;
ai_add_goal_ship_internal( &Ai_info[Ships[num].ai_index], goal_type, name, -1, -1, immediate);
}
}
// this function copies goals from a wing to an ai_info * from a ship.
void ai_copy_mission_wing_goal( ai_goal *aigp, ai_info *aip )
{
@@ -1372,7 +1376,7 @@ void ai_copy_mission_wing_goal( ai_goal *aigp, ai_info *aip )
}
if (j >= MAX_AI_GOALS) {
mprintf(("Unable to assign wing goal to ship %s; the ship goals are already filled to capacity", Ships[aip->shipnum].ship_name));
mprintf(("Unable to assign wing goal to ship %s; the ship goals are already filled to capacity\n", Ships[aip->shipnum].ship_name));
}
}
@@ -1401,7 +1405,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// these orders are always achievable.
if ( (aigp->ai_mode == AI_GOAL_KEEP_SAFE_DISTANCE)
|| (aigp->ai_mode == AI_GOAL_CHASE_ANY) || (aigp->ai_mode == AI_GOAL_STAY_STILL)
|| (aigp->ai_mode == AI_GOAL_PLAY_DEAD) )
|| (aigp->ai_mode == AI_GOAL_PLAY_DEAD) || (aigp->ai_mode == AI_GOAL_PLAY_DEAD_PERSISTENT) )
return AI_GOAL_ACHIEVABLE;
// warp (depart) only achievable if there's somewhere to depart to
@@ -1409,21 +1413,17 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
{
ship *shipp = &Ships[objp->instance];
// always valid if has subspace drive
if (!(shipp->flags[Ship::Ship_Flags::No_subspace_drive]))
// always valid if has working subspace drive, not disabled, and not limited by subsystem strength
if ( ship_can_warp_full_check(shipp) )
return AI_GOAL_ACHIEVABLE;
// if no subspace drive, only valid if our mothership is present
// check that we have a mothership and that we can depart to it
if (shipp->departure_location == DEPART_AT_DOCK_BAY)
{
int anchor_shipnum = ship_name_lookup(Parse_names[shipp->departure_anchor]);
if (anchor_shipnum >= 0 && ship_useful_for_departure(anchor_shipnum, shipp->departure_path_mask))
return AI_GOAL_ACHIEVABLE;
// if we can't warp, we can only depart if the ship (or its wing) departs to a fighter bay and the mothership is present
if (ship_can_bay_depart(shipp)) {
return AI_GOAL_ACHIEVABLE;
}
else {
return AI_GOAL_NOT_KNOWN;
}
return AI_GOAL_NOT_KNOWN;
}
@@ -1502,7 +1502,8 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
Assert ( aigp->ai_submode >= 0 );
ssp = ship_get_indexed_subsys( &Ships[sindex], aigp->ai_submode );
if (ssp != NULL) {
status = mission_log_get_time( LOG_SHIP_SUBSYS_DESTROYED, aigp->target_name, ssp->system_info->subobj_name, NULL );
// see MWA 3/20/97 comment above - instead of checking the mission log, check the current hits
status = (ssp->current_hits <= 0.0f) ? 1 : 0;
} else {
// not supposed to ever happen, but could if there is a mismatch between the table and model subsystems
nprintf(("AI", "Couldn't find subsystem %d for ship %s\n", aigp->ai_submode, Ships[sindex].ship_name));
@@ -1512,12 +1513,36 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
}
case AI_GOAL_DISABLE_SHIP:
status = mission_log_get_time( LOG_SHIP_DISABLED, aigp->target_name, NULL, NULL );
{
// shipnum could be -1 depending on if the ship hasn't arrived or died. only look for subsystem
// destroyed when shipnum is valid
sindex = ship_name_lookup(aigp->target_name);
// can't determine the status of this goal if ship not valid
if (sindex < 0) {
status = 0;
} else {
// see MWA 3/20/97 comment above - instead of checking the mission log, check the current hits
status = (Ships[sindex].subsys_info[SUBSYSTEM_ENGINE].aggregate_current_hits <= 0.0f) ? 1 : 0;
}
break;
}
case AI_GOAL_DISARM_SHIP:
status = mission_log_get_time( LOG_SHIP_DISARMED, aigp->target_name, NULL, NULL );
{
// shipnum could be -1 depending on if the ship hasn't arrived or died. only look for subsystem
// destroyed when shipnum is valid
sindex = ship_name_lookup(aigp->target_name);
// can't determine the status of this goal if ship not valid
if (sindex < 0) {
status = 0;
} else {
// see MWA 3/20/97 comment above - instead of checking the mission log, check the current hits
status = (Ships[sindex].subsys_info[SUBSYSTEM_TURRET].aggregate_current_hits <= 0.0f) ? 1 : 0;
}
break;
}
// to guard or ignore a ship, the goal cannot continue if the ship being guarded is either destroyed
// or has departed.
@@ -1629,7 +1654,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
status = SHIP_STATUS_ARRIVED;
}
// goal ship is still on the arrival list
else if ( mission_parse_get_arrival_ship(aigp->target_name) )
else if ( mission_check_ship_yet_to_arrive(aigp->target_name) )
{
status = SHIP_STATUS_NOT_ARRIVED;
}
@@ -1895,9 +1920,12 @@ int ai_goal_priority_compare(const void *a, const void *b)
// check whether or not the goal override flag is set. If it is set, then push this goal higher
// in the list
else if ( (ga->flags[AI::Goal_Flags::Goal_override]) && !(gb->flags[AI::Goal_Flags::Goal_override]) )
// Goober5000: the ONLY goals we do not override are play-dead and play-dead-persistent,
// because the override flag needs to work in any other situation
else if ( (ga->flags[AI::Goal_Flags::Goal_override]) && !(gb->flags[AI::Goal_Flags::Goal_override]) && !(gb->ai_mode == AI_GOAL_PLAY_DEAD) && !(gb->ai_mode == AI_GOAL_PLAY_DEAD_PERSISTENT) )
return -1;
else if ( !(ga->flags[AI::Goal_Flags::Goal_override]) && (gb->flags[AI::Goal_Flags::Goal_override]) )
else if ( !(ga->flags[AI::Goal_Flags::Goal_override]) && (gb->flags[AI::Goal_Flags::Goal_override]) && !(ga->ai_mode == AI_GOAL_PLAY_DEAD) && !(ga->ai_mode == AI_GOAL_PLAY_DEAD_PERSISTENT))
return 1;
// now normal priority processing
@@ -2290,6 +2318,13 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
aip->submode_start_time = Missiontime;
break;
case AI_GOAL_PLAY_DEAD_PERSISTENT:
// same as above, but we don't clear out ship goals
aip->mode = AIM_PLAY_DEAD;
aip->submode = -1;
aip->submode_start_time = Missiontime;
break;
case AI_GOAL_FORM_ON_WING:
// for form on wing, we need to clear out all goals for this ship, and then call the form
// on wing AI code
+5 -5
View File
@@ -58,16 +58,17 @@ struct ai_goal;
#define AI_GOAL_FLY_TO_SHIP (1<<23) // 0x00800000
#define AI_GOAL_IGNORE_NEW (1<<24) // 0x01000000
#define AI_GOAL_CHASE_SHIP_CLASS (1<<25) // 0x02000000
#define AI_GOAL_PLAY_DEAD_PERSISTENT (1<<26) // 0x03000000
// now the masks for ship types
// Goober5000: added AI_GOAL_STAY_NEAR_SHIP and AI_GOAL_KEEP_SAFE_DISTANCE as valid for fighters
//WMC - Don't need these anymore. Whee!
/*
#define AI_GOAL_ACCEPT_FIGHTER ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_CHASE | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_WARP | AI_GOAL_DESTROY_SUBSYSTEM | AI_GOAL_CHASE_WING | AI_GOAL_GUARD | AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP | AI_GOAL_CHASE_ANY | AI_GOAL_IGNORE | AI_GOAL_IGNORE_NEW | AI_GOAL_GUARD_WING | AI_GOAL_EVADE_SHIP | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD | AI_GOAL_STAY_NEAR_SHIP | AI_GOAL_KEEP_SAFE_DISTANCE )
#define AI_GOAL_ACCEPT_FIGHTER ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_CHASE | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_WARP | AI_GOAL_DESTROY_SUBSYSTEM | AI_GOAL_CHASE_WING | AI_GOAL_GUARD | AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP | AI_GOAL_CHASE_ANY | AI_GOAL_IGNORE | AI_GOAL_IGNORE_NEW | AI_GOAL_GUARD_WING | AI_GOAL_EVADE_SHIP | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD | AI_GOAL_PLAY_DEAD_PERSISTENT | AI_GOAL_STAY_NEAR_SHIP | AI_GOAL_KEEP_SAFE_DISTANCE )
#define AI_GOAL_ACCEPT_BOMBER ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_FIGHTER | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_STEALTH ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_FIGHTER | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_TRANSPORT ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_CHASE | AI_GOAL_CHASE_WING | AI_GOAL_DOCK | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_WARP | AI_GOAL_UNDOCK | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD| AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_TRANSPORT ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_CHASE | AI_GOAL_CHASE_WING | AI_GOAL_DOCK | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_WARP | AI_GOAL_UNDOCK | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD | AI_GOAL_PLAY_DEAD_PERSISTENT | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_FREIGHTER ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_TRANSPORT | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_CRUISER ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_FREIGHTER | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_CORVETTE ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CRUISER | AI_GOAL_STAY_NEAR_SHIP )
@@ -75,7 +76,7 @@ struct ai_goal;
#define AI_GOAL_ACCEPT_AWACS ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CRUISER | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_CAPITAL ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CRUISER & ~(AI_GOAL_DOCK | AI_GOAL_UNDOCK) | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_SUPERCAP ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CAPITAL | AI_GOAL_STAY_NEAR_SHIP )
#define AI_GOAL_ACCEPT_SUPPORT ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_DOCK | AI_GOAL_UNDOCK | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_STAY_NEAR_SHIP | AI_GOAL_KEEP_SAFE_DISTANCE | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD)
#define AI_GOAL_ACCEPT_SUPPORT ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_DOCK | AI_GOAL_UNDOCK | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_STAY_NEAR_SHIP | AI_GOAL_KEEP_SAFE_DISTANCE | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD | AI_GOAL_PLAY_DEAD_PERSISTENT )
#define AI_GOAL_ACCEPT_ESCAPEPOD ( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_TRANSPORT| AI_GOAL_STAY_NEAR_SHIP )
*/
@@ -102,7 +103,7 @@ extern int ai_goal_num(ai_goal *goals);
extern void ai_add_ship_goal_scripting(int mode, int submode, int priority, char *shipname, ai_info *aip);
extern void ai_add_ship_goal_sexp( int sexp, int type, ai_info *aip );
extern void ai_add_wing_goal_sexp( int sexp, int type, int wingnum );
extern void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp );
extern void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name );
extern int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp );
extern void ai_remove_wing_goal_sexp(int sexp, int wingnum);
@@ -127,6 +128,5 @@ extern char *ai_add_dock_name(const char *str);
extern int ai_query_goal_valid( int ship, int ai_goal_type );
extern void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int docker_point, int dockee_point, int immediate = 1 );
extern void ai_add_goal_wing_internal( wing *wingp, int goal_type, char *name, int immediate = 1 );
#endif
+28 -28
View File
@@ -24,7 +24,7 @@
#include "weapon/swarm.h"
#include "weapon/weapon.h"
#include <limits.h>
#include <climits>
// How close a turret has to be point at its target before it
@@ -243,7 +243,7 @@ int bomb_headed_towards_ship(object *bomb_objp, object *ship_objp)
* @note All non-negative return values are expressed in what I like to call "widx"s.
* @return -1 if unable to find a weapon for the target at all.
*/
int turret_select_best_weapon(ship_subsys *turret, object *target)
int turret_select_best_weapon(ship_subsys *turret, object * /*target*/)
{
//TODO: Fill this out with extraodinary gun-picking algorithms
if(turret->weapons.num_primary_banks > 0)
@@ -856,11 +856,11 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
// flags for weapon types
if (beam_flag)
eeo.eeo_flags |= EEOF_BEAM;
else if (flak_flag)
if (flak_flag)
eeo.eeo_flags |= EEOF_FLAK;
else if (laser_flag)
if (laser_flag)
eeo.eeo_flags |= EEOF_LASER;
else if (missile_flag)
if (missile_flag)
eeo.eeo_flags |= EEOF_MISSILE;
eeo.enemy_team_mask = enemy_team_mask;
@@ -1290,7 +1290,9 @@ void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos
model_instance_find_world_point(&tmp_pos, &avg, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos);
if (targetp == nullptr) {
Assertion(ssp->turret_enemy_objnum >= 0, "The turret enemy object number %d for %s on ship number %d is invalid.", ssp->turret_enemy_objnum, ssp->sub_name, ssp->parent_objnum);
ship* shipp = &Ships[Objects[ssp->parent_objnum].instance];
Assertion(ssp->turret_enemy_objnum >= 0, "The turret enemy object number %d for %s on ship name %s is invalid.", ssp->turret_enemy_objnum, ssp->sub_name,
(shipp->has_display_name()) ? shipp->display_name.c_str() : shipp->ship_name);
object *lep = &Objects[ssp->turret_enemy_objnum];
int best_weapon_tidx = turret_select_best_weapon(ssp, lep);
@@ -1301,9 +1303,9 @@ void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos
weapon_info *wip = get_turret_weapon_wip(&ssp->weapons, best_weapon_tidx);
float weapon_system_strength = ship_get_subsystem_strength(&Ships[ssp->parent_objnum], SUBSYSTEM_WEAPONS);
float weapon_system_strength = ship_get_subsystem_strength(shipp, SUBSYSTEM_WEAPONS);
turret_ai_update_aim(&Ai_info[Ships[ssp->parent_objnum].ai_index], &Objects[ssp->turret_enemy_objnum], ssp);
turret_ai_update_aim(&Ai_info[shipp->ai_index], &Objects[ssp->turret_enemy_objnum], ssp);
if ((ssp->targeted_subsys != nullptr) && !(ssp->flags[Ship::Subsystem_Flags::No_SS_targeting])) {
vm_vec_unrotate(&enemy_point, &ssp->targeted_subsys->system_info->pnt, &Objects[ssp->turret_enemy_objnum].orient);
@@ -1676,7 +1678,12 @@ void turret_set_next_fire_timestamp(int weapon_num, weapon_info *wip, ship_subsy
wait *= wip->burst_delay;
turret->weapons.burst_counter[weapon_num]++;
} else {
wait *= wip->fire_wait;
// Random fire delay (DahBlount) used in ship_fire_primary(), added here by wookieejedi to correct oversight
if (wip->max_delay != 0.0f && wip->min_delay != 0.0f) {
wait *= frand_range(wip->min_delay, wip->max_delay);
} else {
wait *= wip->fire_wait;
}
if ((wip->burst_shots > 0) && (wip->burst_flags[Weapon::Burst_Flags::Random_length])) {
turret->weapons.burst_counter[weapon_num] = (myrand() % wip->burst_shots);
} else {
@@ -1805,7 +1812,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
parent_aip = &Ai_info[Ships[Objects[parent_objnum].instance].ai_index];
parent_ship = &Ships[Objects[parent_objnum].instance];
wip = get_turret_weapon_wip(&turret->weapons, weapon_num);
int turret_weapon_class = WEAPON_INFO_INDEX(wip);
int turret_weapon_class = weapon_info_get_index(wip);
#ifndef NDEBUG
// moved here from check_ok_to_fire
@@ -1874,7 +1881,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
turret->last_fired_weapon_info_index = turret_weapon_class;
Script_system.SetHookObjects(4, "Ship", &Objects[parent_objnum], "Weapon", nullptr, "Beam", objp, "Target", &Objects[turret->turret_enemy_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, 0, NULL, &Objects[parent_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, &Objects[parent_objnum]);
Script_system.RemHookVars(4, "Ship", "Weapon", "Beam", "Target");
}
@@ -2009,7 +2016,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
wp->turret_subsys = turret;
Script_system.SetHookObjects(4, "Ship", &Objects[parent_objnum], "Weapon", objp, "Beam", nullptr, "Target", &Objects[turret->turret_enemy_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, 0, NULL, &Objects[parent_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, &Objects[parent_objnum]);
Script_system.RemHookVars(4, "Ship", "Weapon", "Beam", "Target");
// if the gun is a flak gun
@@ -2048,7 +2055,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
}
}
if ( wip->launch_snd != -1 ) {
if ( wip->launch_snd.isValid() ) {
// Don't play turret firing sound if turret sits on player ship... it gets annoying.
if ( parent_objnum != OBJ_INDEX(Player_obj) || (turret->flags[Ship::Subsystem_Flags::Play_sound_for_player]) ) {
snd_play_3d( gamesnd_get_game_sound(wip->launch_snd), turret_pos, &View_position );
@@ -2126,7 +2133,7 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
tsi->turret->last_fired_weapon_info_index = tsi->weapon_class;
Script_system.SetHookObjects(4, "Ship", &Objects[tsi->parent_objnum], "Weapon", &Objects[weapon_objnum], "Beam", nullptr, "Target", &Objects[tsi->turret->turret_enemy_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, 0, NULL, &Objects[tsi->parent_objnum]);
Script_system.RunCondition(CHA_ONTURRETFIRED, &Objects[tsi->parent_objnum]);
Script_system.RemHookVars(4, "Ship", "Weapon", "Beam", "Target");
// muzzle flash?
@@ -2135,7 +2142,7 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
}
// maybe sound
if ( Weapon_info[tsi->weapon_class].launch_snd != -1 ) {
if ( Weapon_info[tsi->weapon_class].launch_snd.isValid() ) {
// Don't play turret firing sound if turret sits on player ship... it gets annoying.
if ( tsi->parent_objnum != OBJ_INDEX(Player_obj) ) {
snd_play_3d( gamesnd_get_game_sound(Weapon_info[tsi->weapon_class].launch_snd), &turret_pos, &View_position );
@@ -2537,7 +2544,6 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
// Ok, the turret is lined up... now line up a particular gun.
bool ok_to_fire = false;
bool something_was_ok_to_fire=false;
vec3d tv2e; //so flak can get their jitter without screwing up other guns
if (in_fov ) {
@@ -2574,7 +2580,9 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
ss->turret_next_fire_pos = ffp_pos;
}
ship_get_global_turret_gun_info(&Objects[parent_objnum], ss, &gpos, &gvec, use_angles, &predicted_enemy_pos);
// We're ready to fire... now get down to specifics, like where is the
// actual gun point and normal, not just the one for whole turret.
ship_get_global_turret_gun_info(&Objects[parent_objnum], ss, &gpos, &gvec, use_angles, &predicted_enemy_pos);
// Fire in the direction the turret is facing, not right at the target regardless of turret dir.
vm_vec_sub(&v2e, &predicted_enemy_pos, &gpos);
@@ -2585,12 +2593,6 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
wip = get_turret_weapon_wip(&ss->weapons, valid_weapons[0]);
else
wip = get_turret_weapon_wip(&ss->weapons, valid_weapons[i]);
// We're ready to fire... now get down to specifics, like where is the
// actual gun point and normal, not just the one for whole turret.
// moved here as if there are two weapons with indentical fire stamps
// they would have shared the fire point.
tv2e = gvec;
// make sure to reset this for current weapon
ok_to_fire = false;
@@ -2598,7 +2600,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
// if the weapon is a flak gun, add some jitter to its aim so it fires in a "cone"
// to make a cool visual effect and make them less lethal
if(wip->wi_flags[Weapon::Info_Flags::Flak]){
flak_jitter_aim(&tv2e, dist_to_enemy, ship_get_subsystem_strength(shipp, SUBSYSTEM_WEAPONS), wip);
flak_jitter_aim(&v2e, dist_to_enemy, ship_get_subsystem_strength(shipp, SUBSYSTEM_WEAPONS), wip);
}
// Fire if:
@@ -2709,9 +2711,9 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
//Pass along which gun we are using
if (tp->flags[Model::Subsystem_Flags::Turret_salvo])
turret_fire_weapon(valid_weapons[0], ss, parent_objnum, &gpos, &tv2e, &predicted_enemy_pos);
turret_fire_weapon(valid_weapons[0], ss, parent_objnum, &gpos, &v2e, &predicted_enemy_pos);
else
turret_fire_weapon(valid_weapons[i], ss, parent_objnum, &gpos, &tv2e, &predicted_enemy_pos);
turret_fire_weapon(valid_weapons[i], ss, parent_objnum, &gpos, &v2e, &predicted_enemy_pos);
} else {
// make sure salvo fire mode does not turn into autofire
if ((tp->flags[Model::Subsystem_Flags::Turret_salvo]) && ((i + 1) == number_of_firings)) {
@@ -2724,8 +2726,6 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
if(!something_was_ok_to_fire)
{
mprintf(("nothing ok to fire\n"));
if (ss->turret_best_weapon >= 0) {
//Impose a penalty on turret accuracy for losing site of its goal, or just not being able to fire.
turret_update_enemy_in_range(ss, -4*Weapon_info[ss->turret_best_weapon].fire_wait);
+2 -171
View File
@@ -274,9 +274,9 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
percent_through = instance->time_elapsed / time;
if(instance->direction == ANIM_DIRECT_FORWARD)
new_frame_num = instance->start_at - 1 + fl2i(percent_through * n_frames + 0.5f);
new_frame_num = instance->start_at - 1 + (int) lround(percent_through * n_frames);
else
new_frame_num = instance->start_at - 1 - fl2i(percent_through * n_frames + 0.5f);
new_frame_num = instance->start_at - 1 - (int) lround(percent_through * n_frames);
frame_save = instance->frame_num;
@@ -519,19 +519,6 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
return 0;
}
/**
* @brief Stop an anim instance that is on the anim_render_list from playing
*/
int anim_stop_playing(anim_instance* instance)
{
Assert(instance != NULL);
if ( anim_playing(instance) ) {
anim_release_render_instance(instance);
}
return 0;
}
/**
* @brief Free a particular animation instance that is on the anim_render_list.
* Do not call this function to free an animation instance in general (use
@@ -866,20 +853,6 @@ int anim_free(anim *ptr)
return 0;
}
/**
* @brief Return if an anim is playing or not.
*/
int anim_playing(anim_instance *ai)
{
Assert(ai != NULL);
if ( ai->frame == NULL )
return 0;
else
return 1;
}
/**
* @brief Called at the beginning of a mission to initialize any mission dependent anim data.
* @todo Redundant?
@@ -896,138 +869,6 @@ void anim_level_close()
anim_release_all_instances();
}
/**
* @brief Write the frames of a .ani file out to disk as .pcx files.
* @details Use naming convention: filename0000.pcx, filename0001.pcx etc.
*
* @return If success 0, or if failed -1
*/
int anim_write_frames_out(char *filename)
{
anim *source_anim;
anim_instance *ai;
char root_name[256], pcxname[256];
char buf[64];
int i,j;
ubyte **row_data;
strcpy_s(root_name, filename);
root_name[strlen(filename)-4] = 0;
source_anim = anim_load(filename);
if ( source_anim == NULL )
return -1;
ai = init_anim_instance(source_anim, 16);
row_data = (ubyte**)vm_malloc((source_anim->height+1) * 4);
for ( i = 0; i < source_anim->total_frames; i++ ) {
anim_get_next_raw_buffer(ai, 0, 0, 16);
strcpy_s(pcxname, root_name);
sprintf(buf,"%04d",i);
strcat_s(pcxname, buf);
for ( j = 0; j < source_anim->height; j++ ) {
row_data[j] = &ai->frame[j*source_anim->width];
}
pcx_write_bitmap( pcxname,
source_anim->width,
source_anim->height,
row_data,
source_anim->palette);
printf(".");
}
printf("\n");
vm_free(row_data);
return 0;
}
/**
* @brief Display information and statistics about a .ani file.
* @details This is called when -i switch is on when running ac.exe
*/
void anim_display_info(char *real_filename)
{
CFILE *fp;
anim A;
float percent;
int i, uncompressed, compressed, *key_frame_nums=NULL, tmp;
char filename[MAX_FILENAME_LEN];
strcpy_s( filename, real_filename );
char *p = strchr( filename, '.' );
if ( p ) {
*p = 0;
}
strcat_s( filename, ".ani" );
fp = cfopen(filename, "rb");
if ( !fp ) {
printf("Fatal error opening %s", filename);
return;
}
anim_read_header(&A, fp);
if (A.width < 0 || A.height < 0) {
Error(LOCATION, "Ani file %s has a faulty header and cannot be loaded.", filename);
}
// read the keyframe frame nums and offsets
key_frame_nums = (int*)vm_malloc(sizeof(int)*A.num_keys);
Assert(key_frame_nums != NULL);
if (key_frame_nums == NULL)
return;
for ( i = 0; i < A.num_keys; i++ ) {
key_frame_nums[i] = 0;
cfread(&key_frame_nums[i], 2, 1, fp);
cfread(&tmp, 4, 1, fp);
}
cfread(&compressed, 4, 1, fp);
uncompressed = A.width * A.height * A.total_frames; // 8 bits per pixel
percent = i2fl(compressed) / uncompressed * 100.0f;
printf("%% of uncompressed size: %.0f%%\n", percent);
printf("Width: %d\n", A.width);
printf("Height: %d\n", A.height);
printf("Total Frames: %d\n", A.total_frames);
#ifndef NDEBUG
printf("Key Frames: %d\n", A.num_keys);
if ( A.num_keys > 1 && (A.total_frames != A.num_keys) ) {
printf("key list: (");
for ( i = 0; i < A.num_keys; i++ ) {
if ( i < A.num_keys-1 )
printf("%d, ", key_frame_nums[i]);
else
printf("%d)\n", key_frame_nums[i]);
}
}
#endif
printf("FPS: %d\n", A.fps);
#ifndef NDEBUG
printf("Transparent RGB: (%u,%u,%u)\n", A.xparent_r, A.xparent_g, A.xparent_b);
#endif
printf("ac version: %d\n", A.version);
if ( key_frame_nums != NULL ) {
vm_free(key_frame_nums);
}
cfclose(fp);
}
void anim_reverse_direction(anim_instance *ai)
{
int temp;
@@ -1061,16 +902,6 @@ void anim_reverse_direction(anim_instance *ai)
}
}
void anim_pause(anim_instance *ai)
{
ai->paused = 1;
}
void anim_unpause(anim_instance *ai)
{
ai->paused = 0;
}
void anim_ignore_next_frametime()
{
Anim_ignore_frametime=1;
-6
View File
@@ -54,19 +54,13 @@ void anim_render_one(int screen_id, anim_instance *ani, float frametime);
void anim_play_init(anim_play_struct *aps, anim *a_info, int x, int y, int max_x = -1, int max_y = -1);
anim_instance *anim_play(anim_play_struct *aps);
void anim_ignore_next_frametime();
int anim_stop_playing(anim_instance* anim_instance);
int anim_show_next_frame(anim_instance *instance, float frametime);
void anim_release_all_instances(int screen_id = 0);
void anim_release_render_instance(anim_instance* instance);
anim *anim_load(const char *name, int cf_dir_type = CF_TYPE_ANY, int file_mapped = PAGE_FROM_DISK);
int anim_free(anim *ptr);
int anim_playing(anim_instance *ai);
int anim_write_frames_out(char *filename);
void anim_display_info(char *filename);
void anim_read_header(anim *ptr, CFILE *fp);
void anim_reverse_direction(anim_instance *ai); // called automatically for ping-ponging, and can also be called externally
void anim_pause(anim_instance *ai);
void anim_unpause(anim_instance *ai);
int anim_instance_is_streamed(anim_instance *ai);
unsigned char anim_instance_get_byte(anim_instance *ai, int offset);
-361
View File
@@ -78,52 +78,6 @@ void free_anim_instance(anim_instance *inst)
vm_free(inst);
}
int anim_get_next_frame(anim_instance *inst)
{
int bm, bitmap_flags;
int aabitmap = 0;
int bpp = 16;
if ( anim_instance_is_streamed(inst) ) {
if ( inst->file_offset <= 0 ) {
return -1;
}
} else {
if (!inst->data)
return -1;
}
inst->frame_num++;
if (inst->frame_num >= inst->parent->total_frames) {
inst->data = NULL;
inst->file_offset = inst->parent->file_offset;
return -1;
}
bitmap_flags = 0;
bpp = 16;
if(inst->aa_color != NULL){
bitmap_flags |= BMP_AABITMAP;
aabitmap = 1;
bpp = 8;
}
anim_check_for_palette_change(inst);
BM_SELECT_TEX_FORMAT();
if ( anim_instance_is_streamed(inst) ) {
inst->file_offset = unpack_frame_from_file(inst, inst->frame, inst->parent->width*inst->parent->height, inst->parent->palette_translation, aabitmap, bpp);
} else {
inst->data = unpack_frame(inst, inst->data, inst->frame, inst->parent->width*inst->parent->height, inst->parent->palette_translation, aabitmap, bpp);
}
bm = bm_create(bpp, inst->parent->width, inst->parent->height, inst->frame, bitmap_flags);
bm_unload(bm);
return bm;
}
ubyte *anim_get_next_raw_buffer(anim_instance *inst, int xlate_pal, int aabitmap, int bpp)
{
if ( anim_instance_is_streamed(inst) ) {
@@ -162,321 +116,6 @@ ubyte *anim_get_next_raw_buffer(anim_instance *inst, int xlate_pal, int aabitmap
return inst->frame;
}
/**
* @brief Pack key frame
*
* @param frame Frame pixel data to pack
* @param save Memory to store packed data to
* @param size Number of bytes to pack
* @param max Maximum number of packed bytes (size of buffer)
* @param compress_type Compress type
* @return Actual number of bytes data packed to or -1 if error
*/
int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_type)
{
int last = -32768, count = 0;
long packed_size = 1;
switch ( compress_type ) {
case PACKING_METHOD_RLE_KEY:
*save++ = PACKING_METHOD_RLE_KEY;
while (size--) {
if (*frame != last || count > 255) {
if (packed_size + 3 >= max)
return -1;
if (count < 3) {
if (last == packer_code) {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
packed_size += 2;
} else
while (count--) {
*save++ = (ubyte)last;
packed_size++;
}
} else {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
*save++ = (ubyte)last;
packed_size += 3;
}
count = 0;
last = *frame;
}
count++;
frame++;
}
if (packed_size + 3 >= max)
return -1;
if (count < 3) {
if (last == packer_code) {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
packed_size += 2;
} else
while (count--) {
*save++ = (ubyte)last;
packed_size++;
}
} else {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
*save++ = (ubyte)last;
packed_size += 3;
}
break;
case PACKING_METHOD_STD_RLE_KEY: {
ubyte *dest_start;
int i;
dest_start = save;
count = 1;
last = *frame++;
*save++ = PACKING_METHOD_STD_RLE_KEY;
for (i=1; i < size; i++ ) {
if ( *frame != last ) {
if ( count ) {
if (packed_size + 2 >= max)
return -1;
if ( (count == 1) && !(last & STD_RLE_CODE) ) {
*save++ = (ubyte)last;
packed_size++;
Assert( last != STD_RLE_CODE );
}
else {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
}
}
last = *frame;
count = 0;
}
count++;
frame++;
if ( count == 127 ) {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
count = 0;
}
} // end for
if (count) {
if (packed_size + 2 >= max)
return -1;
if ( (count == 1) && !(last & STD_RLE_CODE) ) {
*save++ = (ubyte)last;
packed_size++;
Assert( last != STD_RLE_CODE );
}
else {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
}
}
Assert(packed_size == (save-dest_start) );
return packed_size;
}
default:
Assert(0);
return -1;
break;
} // end switch
return packed_size;
}
/**
* @brief Pack frame
*
* @param frame Frame pixel data to pack
* @param frame2 Previous frame's pixel data
* @param save Memory to store packed data to
* @param size Number of bytes to pack
* @param max Maximum number of packed bytes (size of buffer)
* @param compress_type Compress type
* @return Actual number of bytes data packed to or -1 if error
*/
int pack_frame(ubyte *frame, ubyte *frame2, ubyte *save, long size, long max, int compress_type)
{
int pixel, last = -32768, count = 0, i;
long packed_size = 1;
switch ( compress_type ) {
case PACKING_METHOD_RLE: // Hoffoss RLE regular frame
*save++ = PACKING_METHOD_RLE;
while (size--) {
if (*frame != *frame2++)
pixel = *frame;
else
pixel = transparent_code;
if (pixel != last || count > 255) {
if (packed_size + 3 >= max)
return -1;
if (count < 3) {
if (last == packer_code) {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
packed_size += 2;
} else
while (count--) {
*save++ = (ubyte)last;
packed_size++;
}
} else {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
*save++ = (ubyte)last;
packed_size += 3;
}
count = 0;
last = pixel;
}
frame++;
count++;
}
if (packed_size + 3 >= max)
return -1;
if (count < 3) {
if (last == packer_code) {
*save++ = (ubyte)packer_code;
*save++ = (ubyte)(count - 1);
packed_size += 2;
} else
while (count--) {
*save++ = (ubyte)last;
packed_size++;
}
} else {
*save++ = (ubyte)(packer_code);
*save++ = (ubyte)(count - 1);
*save++ = (ubyte)(last);
packed_size += 3;
}
break;
case PACKING_METHOD_STD_RLE: { // high bit count regular RLE frame
ubyte *dest_start;
dest_start = save;
count = 1;
if (*frame++ != *frame2++)
last = *frame;
else
last = transparent_code;
*save++ = PACKING_METHOD_STD_RLE;
for (i=1; i < size; i++ ) {
if (*frame != *frame2++)
pixel = *frame;
else
pixel = transparent_code;
if ( pixel != last ) {
if ( count ) {
if (packed_size + 2 >= max)
return -1;
if ( (count == 1) && !(last & STD_RLE_CODE) ) {
*save++ = (ubyte)last;
packed_size++;
Assert( last != STD_RLE_CODE );
}
else {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
}
}
last = pixel;
count = 0;
}
count++;
frame++;
if ( count == 127 ) {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
count = 0;
}
} // end for
if (count) {
if (packed_size + 2 >= max)
return -1;
if ( (count == 1) && !(last & STD_RLE_CODE) ) {
*save++ = (ubyte)last;
packed_size++;
Assert( last != STD_RLE_CODE );
}
else {
count |= STD_RLE_CODE;
*save++ = (ubyte)count;
*save++ = (ubyte)last;
packed_size += 2;
}
}
Assert(packed_size == (save-dest_start) );
return packed_size;
}
default:
Assert(0);
return -1;
break;
} // end switch
return packed_size;
}
/**
* @brief Convert a 24 bit value to a 16 bit value
* @param bit_24 24 bit value
-4
View File
@@ -97,16 +97,12 @@ typedef struct anim_instance {
int loop_count; // starts at 0, and is incremented each time it loops
} anim_instance;
int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_type);
int pack_frame(ubyte *frame, ubyte *frame2, ubyte *save, long size, long max, int compress_type);
ubyte *unpack_frame(anim_instance *ai, ubyte *ptr, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp);
int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp);
void anim_init();
anim_instance *init_anim_instance(anim *ptr, int bpp);
void free_anim_instance(anim_instance *inst);
int anim_get_next_frame(anim_instance *inst);
ubyte *anim_get_next_raw_buffer(anim_instance *inst, int xlate_pal, int aabitmap, int bpp);
void anim_set_palette(anim *a);
void anim_check_for_palette_change(anim_instance *inst);
+45 -109
View File
@@ -76,7 +76,7 @@ float Asteroid_icon_closeup_zoom;
/**
* Force updating of pair stuff for asteroid *objp.
*/
void asteroid_update_collide(object *objp)
static void asteroid_update_collide(object *objp)
{
// Asteroid has wrapped, update collide objnum and flags
Asteroids[objp->instance].collide_objnum = -1;
@@ -87,7 +87,7 @@ void asteroid_update_collide(object *objp)
/**
* Clear out the ::Asteroid_obj_list
*/
void asteroid_obj_list_init()
static void asteroid_obj_list_init()
{
int i;
@@ -101,7 +101,7 @@ void asteroid_obj_list_init()
* Add a node from the Asteroid_obj_list.
* Only called from ::weapon_create()
*/
int asteroid_obj_list_add(int objnum)
static int asteroid_obj_list_add(int objnum)
{
int index;
@@ -123,7 +123,7 @@ int asteroid_obj_list_add(int objnum)
* Remove a node from the Asteroid_obj_list.
* Only called from ::weapon_delete()
*/
void asteroid_obj_list_remove(object * obj)
static void asteroid_obj_list_remove(object * obj)
{
int index = obj->instance;
@@ -138,7 +138,7 @@ void asteroid_obj_list_remove(object * obj)
/**
* Prevent speed from getting too huge so it's hard to catch up to an asteroid.
*/
float asteroid_cap_speed(int asteroid_info_index, float speed)
static float asteroid_cap_speed(int asteroid_info_index, float speed)
{
float max, double_max;
@@ -164,7 +164,7 @@ float asteroid_cap_speed(int asteroid_info_index, float speed)
* Sum together the following: 1 inside x, 2 inside y, 4 inside z
* inside only when sum = 7
*/
int asteroid_in_inner_bound_with_axes(asteroid_field *asfieldp, vec3d *pos, float delta)
static int asteroid_in_inner_bound_with_axes(asteroid_field *asfieldp, vec3d *pos, float delta)
{
Assert(asfieldp->has_inner_bound);
@@ -188,7 +188,7 @@ int asteroid_in_inner_bound_with_axes(asteroid_field *asfieldp, vec3d *pos, floa
* Check if asteroid is within inner bound
* @return 0 if not inside or no inner bound, 1 if inside inner bound
*/
int asteroid_in_inner_bound(asteroid_field *asfieldp, vec3d *pos, float delta) {
static int asteroid_in_inner_bound(asteroid_field *asfieldp, vec3d *pos, float delta) {
if (!asfieldp->has_inner_bound) {
return 0;
@@ -202,7 +202,7 @@ int asteroid_in_inner_bound(asteroid_field *asfieldp, vec3d *pos, float delta) {
*
* Moves to the other side of the inner box a distance delta from edge of box
*/
void inner_bound_pos_fixup(asteroid_field *asfieldp, vec3d *pos)
static void inner_bound_pos_fixup(asteroid_field *asfieldp, vec3d *pos)
{
if (!asteroid_in_inner_bound(asfieldp, pos, 0)) {
return;
@@ -446,7 +446,7 @@ void asteroid_sub_create(object *parent_objp, int asteroid_type, vec3d *relvec)
/**
* Load in an asteroid model
*/
void asteroid_load(int asteroid_info_index, int asteroid_subtype)
static void asteroid_load(int asteroid_info_index, int asteroid_subtype)
{
int i;
asteroid_info *asip;
@@ -478,7 +478,7 @@ void asteroid_load(int asteroid_info_index, int asteroid_subtype)
}
else
{
nprintf(("Warning", "For asteroid '%s', detail level mismatch (POF needs %d)", asip->name, pm->n_detail_levels));
nprintf(("Warning", "For asteroid '%s', detail level mismatch (POF needs %d)\n", asip->name, pm->n_detail_levels));
}
}
// Stuff detail level distances.
@@ -487,26 +487,12 @@ void asteroid_load(int asteroid_info_index, int asteroid_subtype)
}
}
/**
* Randomly choose a debris model within the current group
*/
int get_debris_from_same_group(int index) {
int group_base, group_offset;
group_base = (index / NUM_DEBRIS_SIZES) * NUM_DEBRIS_SIZES;
group_offset = index - group_base;
// group base + offset
// offset is formed by adding 1 or 2 (since 3 in model group) and mapping back in the 0-2 range
return group_base + ((group_offset + rand()%(NUM_DEBRIS_SIZES-1) + 1) % NUM_DEBRIS_SIZES);
}
/**
* Returns a weight that depends on asteroid size.
*
* The weight is then used to determine the frequencty of different sizes of ship debris
*/
int get_debris_weight(int ship_debris_index)
static int get_debris_weight(int ship_debris_index)
{
int size = ship_debris_index % NUM_DEBRIS_SIZES;
switch (size)
@@ -626,7 +612,7 @@ void asteroid_create_all()
}
/**
* Init asteriod system for the level, called from ::game_level_init()
* Init asteroid system for the level, called from ::game_level_init()
*/
void asteroid_level_init()
{
@@ -645,7 +631,7 @@ void asteroid_level_init()
*
* @return !0 if asteroid should be wrapped, 0 otherwise.
*/
int asteroid_should_wrap(object *objp, asteroid_field *asfieldp)
static int asteroid_should_wrap(object *objp, asteroid_field *asfieldp)
{
if ( MULTIPLAYER_CLIENT )
return 0;
@@ -690,7 +676,7 @@ int asteroid_should_wrap(object *objp, asteroid_field *asfieldp)
/**
* Wrap an asteroid from one end of the asteroid field to the other
*/
void asteroid_wrap_pos(object *objp, asteroid_field *asfieldp)
static void asteroid_wrap_pos(object *objp, asteroid_field *asfieldp)
{
if (objp->pos.xyz.x < asfieldp->min_bound.xyz.x) {
objp->pos.xyz.x = asfieldp->max_bound.xyz.x + (objp->pos.xyz.x - asfieldp->min_bound.xyz.x);
@@ -727,7 +713,7 @@ void asteroid_wrap_pos(object *objp, asteroid_field *asfieldp)
*
* @return !0 if this asteroid is a target for any ship, otherwise return 0
*/
int asteroid_is_targeted(object *objp)
static int asteroid_is_targeted(object *objp)
{
ship_obj *so;
object *ship_objp;
@@ -748,7 +734,7 @@ int asteroid_is_targeted(object *objp)
/**
* Create an asteroid that will hit object *objp in delta_time seconds
*/
void asteroid_aim_at_target(object *objp, object *asteroid_objp, float delta_time)
static void asteroid_aim_at_target(object *objp, object *asteroid_objp, float delta_time)
{
vec3d predicted_center_pos;
vec3d rand_vec;
@@ -776,7 +762,7 @@ void asteroid_aim_at_target(object *objp, object *asteroid_objp, float delta_tim
*
* @param count asteroids already targeted on
*/
void maybe_throw_asteroid(int count)
static void maybe_throw_asteroid(int count)
{
if (!timestamp_elapsed(Next_asteroid_throw)) {
return;
@@ -850,7 +836,7 @@ void asteroid_delete( object * obj )
* See if we should reposition the asteroid.
* Only reposition if oustide the bounding volume and the player isn't looking towards the asteroid.
*/
void asteroid_maybe_reposition(object *objp, asteroid_field *asfieldp)
static void asteroid_maybe_reposition(object *objp, asteroid_field *asfieldp)
{
// passive field does not wrap
if (asfieldp->field_type == FT_PASSIVE) {
@@ -903,7 +889,7 @@ void asteroid_maybe_reposition(object *objp, asteroid_field *asfieldp)
}
}
void lerp(float *goal, float f1, float f2, float scale)
static void lerp(float *goal, float f1, float f2, float scale)
{
*goal = (f2 - f1) * scale + f1;
}
@@ -1157,8 +1143,6 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
// SET PHYSICS PARAMETERS
// already have (hitpos - heavy) and light_cm_pos
// get heavy cm pos - already have light_cm_pos
asteroid_hit_info->heavy_collision_cm_pos = zero;
// get r_heavy and r_light
asteroid_hit_info->r_heavy = asteroid_hit_info->hit_pos;
@@ -1207,7 +1191,7 @@ void asteroid_render(object * obj, model_draw_list *scene)
/**
* Create a normalized vector generally in the direction from *hitpos to other_obj->pos
*/
void asc_get_relvec(vec3d *relvec, object *other_obj, vec3d *hitpos)
static void asc_get_relvec(vec3d *relvec, object *other_obj, vec3d *hitpos)
{
vec3d tvec, rand_vec;
int count = 0;
@@ -1229,7 +1213,7 @@ void asc_get_relvec(vec3d *relvec, object *other_obj, vec3d *hitpos)
/**
* Return multiplier on asteroid radius for fireball
*/
float asteroid_get_fireball_scale_multiplier(int num)
static float asteroid_get_fireball_scale_multiplier(int num)
{
if (Asteroids[num].flags & AF_USED) {
asteroid_info *asip = &Asteroid_info[Asteroids[num].asteroid_type];
@@ -1258,7 +1242,7 @@ float asteroid_get_fireball_scale_multiplier(int num)
* Create asteroid explosion
* @return expected time for explosion anim to last, in seconds
*/
float asteroid_create_explosion(object *objp)
static float asteroid_create_explosion(object *objp)
{
int fireball_objnum;
float explosion_life, fireball_scale_multiplier;
@@ -1277,7 +1261,7 @@ float asteroid_create_explosion(object *objp)
fireball_scale_multiplier = asteroid_get_fireball_scale_multiplier(objp->instance);
fireball_objnum = fireball_create( &objp->pos, fireball_type, FIREBALL_LARGE_EXPLOSION, OBJ_INDEX(objp), objp->radius*fireball_scale_multiplier, 0, &objp->phys_info.vel );
fireball_objnum = fireball_create( &objp->pos, fireball_type, FIREBALL_LARGE_EXPLOSION, OBJ_INDEX(objp), objp->radius*fireball_scale_multiplier, false, &objp->phys_info.vel );
if ( fireball_objnum > -1 ) {
explosion_life = fireball_lifeleft(&Objects[fireball_objnum]);
} else {
@@ -1290,23 +1274,23 @@ float asteroid_create_explosion(object *objp)
/**
* Play sound when asteroid explodes
*/
void asteriod_explode_sound(object *objp, int type, int play_loud)
static void asteroid_explode_sound(object *objp, int type, int play_loud)
{
int sound_index = -1;
gamesnd_id sound_index;
float range_factor = 1.0f; // how many times sound should traver farther than normal
if (type % NUM_DEBRIS_SIZES <= 1)
{
sound_index = SND_ASTEROID_EXPLODE_SMALL;
sound_index = gamesnd_id(GameSounds::ASTEROID_EXPLODE_SMALL);
range_factor = 5.0;
}
else
{
sound_index = SND_ASTEROID_EXPLODE_LARGE;
sound_index = gamesnd_id(GameSounds::ASTEROID_EXPLODE_LARGE);
range_factor = 10.0f;
}
Assert(sound_index != -1);
Assert(sound_index.isValid());
if ( !play_loud ) {
range_factor = 1.0f;
@@ -1318,9 +1302,9 @@ void asteriod_explode_sound(object *objp, int type, int play_loud)
/**
* Do the area effect for an asteroid exploding
*
* @param asteroid_objp object pointer to asteriod causing explosion
* @param asteroid_objp object pointer to asteroid causing explosion
*/
void asteroid_do_area_effect(object *asteroid_objp)
static void asteroid_do_area_effect(object *asteroid_objp)
{
object *ship_objp;
float damage, blast;
@@ -1382,7 +1366,7 @@ void asteroid_hit( object * pasteroid_obj, object * other_obj, vec3d * hitpos, f
explosion_life = asteroid_create_explosion(pasteroid_obj);
asteriod_explode_sound(pasteroid_obj, asp->asteroid_type, play_loud_collision);
asteroid_explode_sound(pasteroid_obj, asp->asteroid_type, play_loud_collision);
asteroid_do_area_effect(pasteroid_obj);
asp->final_death_time = timestamp( fl2i(explosion_life*1000.0f)/5 ); // Wait till 30% of vclip time before breaking the asteroid up.
@@ -1401,7 +1385,7 @@ void asteroid_hit( object * pasteroid_obj, object * other_obj, vec3d * hitpos, f
weapon_info *wip;
wip = &Weapon_info[Weapons[other_obj->instance].weapon_info_index];
// If the weapon didn't play any impact animation, play custom asteroid impact animation
if ( wip->impact_weapon_expl_effect < 0 ) {
if (!wip->impact_weapon_expl_effect.isValid()) {
particle::create( hitpos, &vmd_zero_vector, 0.0f, Asteroid_impact_explosion_radius, particle::PARTICLE_BITMAP, Asteroid_impact_explosion_ani );
}
}
@@ -1432,35 +1416,6 @@ void asteroid_level_close()
DCF_BOOL2(asteroids, Asteroids_enabled, "enables or disables asteroids", "Usage: asteroids [bool]\nTurns asteroid system on/off. If nothing passed, then toggles it.\n");
void hud_target_asteroid()
{
int i;
int start_index = 0, end_index = MAX_ASTEROIDS;
if (Player_ai->target_objnum != -1) {
if (Objects[Player_ai->target_objnum].type == OBJ_ASTEROID) {
start_index = Objects[Player_ai->target_objnum].instance+1;
end_index = start_index-1;
if (end_index < 0)
end_index = MAX_ASTEROIDS;
}
}
i = start_index;
while (i != end_index) {
if (i == MAX_ASTEROIDS)
i = 0;
if (Asteroids[i].flags & AF_USED) {
Assert(Objects[Asteroids[i].objnum].type == OBJ_ASTEROID);
set_target_objnum( Player_ai, Asteroids[i].objnum);
break;
}
i++;
}
}
/**
* Return the number of active asteroids
*/
@@ -1473,7 +1428,7 @@ int asteroid_count()
* See if asteroid should split up.
* We delay splitting up to allow the explosion animation to play for a bit.
*/
void asteroid_maybe_break_up(object *pasteroid_obj)
static void asteroid_maybe_break_up(object *pasteroid_obj)
{
asteroid *asp;
asteroid_info *asip;
@@ -1590,31 +1545,12 @@ void asteroid_maybe_break_up(object *pasteroid_obj)
}
asp->final_death_time = timestamp(-1);
}
Script_system.RunCondition(CHA_DEATH, '\0', NULL, pasteroid_obj);
Script_system.RunCondition(CHA_DEATH, pasteroid_obj);
Script_system.RemHookVar("Self");
}
}
int asteroid_get_random_in_cone(vec3d *pos, vec3d *dir, float ang, int danger)
{
int idx;
vec3d asteroid_dir;
// just pick the first asteroid which satisfies our condition
for(idx=0; idx<Num_asteroids; idx++){
vm_vec_sub(&asteroid_dir, &Objects[Asteroids[idx].objnum].pos, pos);
vm_vec_normalize_quick(&asteroid_dir);
// if it satisfies the condition
if(vm_vec_dot(dir, &asteroid_dir) >= ang){
return idx;
}
}
return -1;
}
void asteroid_test_collide(object *pasteroid_obj, object *pship_obj, mc_info *mc, bool lazy = false)
static void asteroid_test_collide(object *pasteroid_obj, object *pship_obj, mc_info *mc, bool lazy = false)
{
float asteroid_ray_dist;
vec3d asteroid_fvec, terminus;
@@ -1656,7 +1592,7 @@ void asteroid_test_collide(object *pasteroid_obj, object *pship_obj, mc_info *mc
*
* @return !0 if the asteroid will collide with the escort
*/
int asteroid_will_collide(object *pasteroid_obj, object *escort_objp)
static int asteroid_will_collide(object *pasteroid_obj, object *escort_objp)
{
mc_info mc;
mc_info_init(&mc);
@@ -1674,7 +1610,7 @@ int asteroid_will_collide(object *pasteroid_obj, object *escort_objp)
* Warn if asteroid on collision path with ship
* @return !0 if we should warn about asteroid hitting ship, otherwise return 0
*/
int asteroid_valid_ship_to_warn_collide(ship *shipp)
static int asteroid_valid_ship_to_warn_collide(ship *shipp)
{
if ( !(Ship_info[shipp->ship_info_index].is_big_or_huge()) ) {
return 0;
@@ -1696,7 +1632,7 @@ int asteroid_valid_ship_to_warn_collide(ship *shipp)
* See if asteroid will collide with a large ship on the escort list in the next
* ASTEROID_MIN_COLLIDE_TIME seconds.
*/
void asteroid_update_collide_flag(object *asteroid_objp)
static void asteroid_update_collide_flag(object *asteroid_objp)
{
int i, num_escorts, escort_objnum, will_collide=0;
ship *escort_shipp;
@@ -1735,7 +1671,7 @@ void asteroid_update_collide_flag(object *asteroid_objp)
/**
* Ensure that the collide objnum for the asteroid is still valid
*/
void asteroid_verify_collide_objnum(asteroid *asp)
static void asteroid_verify_collide_objnum(asteroid *asp)
{
if ( asp->collide_objnum >= 0 ) {
if ( Objects[asp->collide_objnum].signature != asp->collide_objsig ) {
@@ -1815,7 +1751,7 @@ float asteroid_time_to_impact(object *asteroid_objp)
/**
* Read in a single asteroid section from asteroid.tbl
*/
void asteroid_parse_section(asteroid_info *asip)
static void asteroid_parse_section(asteroid_info *asip)
{
required_string("$Name:");
stuff_string(asip->name, F_NAME, NAME_LENGTH);
@@ -1915,7 +1851,7 @@ to do with the debris of ships that explode, however these
are the same debris and asteroids that get flung at a ship
that is being protected.
*/
void asteroid_parse_tbl()
static void asteroid_parse_tbl()
{
char impact_ani_file[MAX_FILENAME_LEN];
@@ -2001,11 +1937,11 @@ void asteroid_parse_tbl()
if (tally != max_asteroids)
{
#ifndef NDEBUG
mprintf(("Asteroid.tbl as parsed:\n"));
for (SCP_vector<SCP_string>::iterator iter = parsed_asteroids.begin();
iter != parsed_asteroids.end(); ++iter)
{
mprintf(("Asteroid.tbl as parsed:\n"));
mprintf(("%s", iter->c_str()));
mprintf(("%s\n", iter->c_str()));
}
#endif
Error(LOCATION,
@@ -2066,7 +2002,7 @@ void asteroid_parse_tbl()
/**
* Return number of asteroids expected to collide with a ship.
*/
int count_incident_asteroids()
static int count_incident_asteroids()
{
object *asteroid_objp;
int count;
@@ -2090,7 +2026,7 @@ int count_incident_asteroids()
* Pick object to throw asteroids at.
* Pick any capital or big ship inside the bounds of the asteroid field.
*/
int set_asteroid_throw_objnum()
static int set_asteroid_throw_objnum()
{
if (Asteroid_field.num_initial_asteroids < 1)
return -1;
-1
View File
@@ -163,7 +163,6 @@ int asteroid_collide_objnum(object *asteroid_objp);
float asteroid_time_to_impact(object *asteroid_objp);
void asteroid_show_brackets();
void asteroid_target_closest_danger();
int asteroid_get_random_in_cone(vec3d *pos, vec3d *dir, float ang, int danger = 0);
// need to extern for multiplayer
void asteroid_sub_create(object *parent_objp, int asteroid_type, vec3d *relvec);
+5 -51
View File
@@ -122,31 +122,6 @@ vec3d *NavPoint::GetPosition()
}
}
char* NavPoint::GetInternalName()
{
char *NavName;
char strtmp[33];
if (flags & NP_WAYPOINT)
{
NavName = new char[strlen(((waypoint_list*)target_obj)->get_name())+5];
memset(NavName, 0, strlen(((waypoint_list*)target_obj)->get_name())+5);
strcpy(NavName, ((waypoint_list*)target_obj)->get_name());
strcat(NavName, ":");
sprintf(strtmp, "%d", waypoint_num);
strcat(NavName, strtmp);
}
else
{
NavName = new char[strlen(((ship*)target_obj)->ship_name)+1];
memset(NavName, 0, strlen(((ship*)target_obj)->ship_name)+1);
strcpy(NavName, ((ship*)target_obj)->ship_name);
}
return NavName;
}
// ********************************************************************************************
bool CanAutopilot(vec3d targetPos, bool send_msg)
{
@@ -243,9 +218,9 @@ bool StartAutopilot()
if (shipp->team != Player_ship->team)
continue;
Assertion((shipp->ship_info_index >= 0) && (shipp->ship_info_index < static_cast<int>(Ship_info.size())),
Assertion((shipp->ship_info_index >= 0) && (shipp->ship_info_index < ship_info_size()),
"Ship '%s' does not have a valid pointer to a ship class. Pointer is %d, which is smaller than 0 or bigger than %d",
shipp->ship_name, shipp->ship_info_index, static_cast<int>(Ship_info.size()));
shipp->ship_name, shipp->ship_info_index, ship_info_size());
ship_info *sip = &Ship_info[shipp->ship_info_index];
if ( !(sip->flags[Ship::Info_Flags::Support]) )
@@ -998,7 +973,6 @@ camera* nav_get_set_camera()
return nav_camera.getCamera();
}
extern int Cmdline_old_collision_sys;
void nav_warp(bool prewarp=false)
{
/* ok... find our end distance - norm1 is still a unit vector in the
@@ -1053,11 +1027,7 @@ void nav_warp(bool prewarp=false)
}
// retime all collision pairs
if ( Cmdline_old_collision_sys ) {
obj_all_collisions_retime();
} else {
obj_collide_retime_cached_pairs();
}
obj_collide_retime_cached_pairs();
}
// ********************************************************************************************
@@ -1231,7 +1201,7 @@ void send_autopilot_msg(char *msg, char *snd)
audio_handle = -1;
}
if (msg[0] != '\0' && strcmp(msg, "none"))
if (msg[0] != '\0' && strcmp(msg, "none") != 0)
change_message("autopilot builtin message", msg, -1, 0);
// load sound
@@ -1246,7 +1216,7 @@ void send_autopilot_msg(char *msg, char *snd)
audiostream_play(audio_handle, (Master_event_music_volume * aav_music_volume), 0);
}
if (msg[0] != '\0' && strcmp(msg, "none"))
if (msg[0] != '\0' && strcmp(msg, "none") != 0)
message_training_queue("autopilot builtin message", timestamp(0), 5); // display message for five seconds
}
@@ -1464,22 +1434,6 @@ bool AddNav_Waypoint(char *Nav, char *WP_Path, int node, int flags)
}
// ********************************************************************************************
//Change Flags
bool Nav_Alt_Flags(char *Nav, int flags)
{
flags &= ~NP_VALIDTYPE; //clear the NP_SHIP and NP_WAYPOINT bits, make sure they haven't been set
int nav = FindNav(Nav);
if (nav != -1)
{
Navs[nav].flags &= NP_VALIDTYPE; // Clear all bits BUT NP_SHIP or NO_WAYPOINT
Navs[nav].flags |= flags; // merge
}
return (nav != -1);
}
//Get Flags
int Nav_Get_Flags(char *Nav)
{
-7
View File
@@ -36,7 +36,6 @@ public:
int waypoint_num; //only used when flags & NP_WAYPOINT
vec3d *GetPosition();
char* GetInternalName();
void clear()
{
@@ -129,9 +128,6 @@ void SelectNav(char *Nav);
// Deselects any navpoint selected.
void DeselectNav();
// Set A Nav point to "ZERO"
void ZeroNav(int i);
// Removes a Nav
bool DelNavPoint(char *Nav);
bool DelNavPoint(int nav);
@@ -140,9 +136,6 @@ bool DelNavPoint(int nav);
bool AddNav_Ship(char *Nav, char *TargetName, int flags);
bool AddNav_Waypoint(char *Nav, char *WP_Path, int node, int flags);
//Change Flags
bool Nav_Alt_Flags(char *Nav, int flags);
// Sexp Accessors
bool Nav_Set_Flag(char *Nav, int flag);
bool Nav_UnSet_Flag(char *Nav, int flag);
+37 -11
View File
@@ -23,6 +23,16 @@
#include "bmpman/bmpman.h"
#include <array>
/**
* @brief Container class for graphics API specific bitmap data
*/
class gr_bitmap_info {
public:
virtual ~gr_bitmap_info() = 0;
};
union bm_extra_info {
struct {
// Stuff needed for animations
@@ -57,9 +67,7 @@ struct bitmap_entry {
char filename[MAX_FILENAME_LEN]; //!< filename for this bitmap
uint signature; //!< a unique signature identifying the data
uint palette_checksum; //!< checksum used to be sure bitmap is in current palette
int handle; //!< Handle = id*MAX_BITMAPS + bitmapnum
int last_used; //!< When this bitmap was last used
BM_TYPE type; //!< PCX, USER, ANI, etc
BM_TYPE comp_type; //!< What sort of compressed type, BM_TYPE_NONE if not compressed
@@ -90,17 +98,35 @@ struct bitmap_entry {
#endif
};
extern bitmap_entry* bm_bitmaps;
struct bitmap_slot {
bitmap_entry entry;
gr_bitmap_info* gr_info = nullptr;
};
// image specific lock functions
void bm_lock_ani( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_dds( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_png( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_apng( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_jpg( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_pcx( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_tga( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_user( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_ani( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_dds( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_png( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_apng( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_jpg( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_pcx( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_tga( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_user( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
const size_t BM_BLOCK_SIZE = 4096;
extern SCP_vector<std::array<bitmap_slot, BM_BLOCK_SIZE>> bm_blocks;
bitmap_slot* bm_get_slot(int handle, bool separate_ani_frames = true);
inline bitmap_entry* bm_get_entry(int handle, bool separate_ani_frames = true) {
return &bm_get_slot(handle, separate_ani_frames)->entry;
}
template<typename T>
T* bm_get_gr_info(int handle, bool separate_ani_frames = true) {
return static_cast<T*>(bm_get_slot(handle, separate_ani_frames)->gr_info);
}
#endif // __BM_INTERNAL_H__
+714 -841
View File
File diff suppressed because it is too large. Load diff
+16 -102
View File
@@ -32,23 +32,6 @@
* @{
*/
/**
* @brief How many bitmaps the game can handle by default
*
* @attention MAX_BITMAPS shouldn't need to be bumped again. With the fixed bm_release() and it's proper use even the
* largest missions should stay under this number. With the largest retail missions and wasteful content we should
* still have about 20% of the slots free. If it still goes over then it's something the artists need to fix.
* For instance the Terran Mara fighter, with -spec and -glow and using the Shinepack, needs 117 bitmap slots alone.
* 111 of those is just for the glowmaps. This number can be greatly reduced if the number of ani frames for another
* LOD than LOD0 has fewer or no ani frames. A 37 frame glow ani for LOD2 is little more than a waste of resources.
* Future reports of texture corruption should be initially approached with content as the cause and not code.
* If anything we could/should reduce MAX_BITMAPS in the future. Where it's at now should accomidate even the
* largest mods. -- Taylor
*/
#define DEFAULT_MAX_BITMAPS 4750
extern int MAX_BITMAPS;
// Flag positions for bitmap.flags
// ***** NOTE: bitmap.flags is an 8-bit value, no more BMP_TEX_* flags can be added unless the type is changed!! ******
#define BMP_AABITMAP (1<<0) //!< antialiased bitmap
@@ -115,6 +98,10 @@ struct bitmap
*/
};
// Forward definition for the graphics API
struct bitmap_entry;
struct bitmap_slot;
extern size_t bm_texture_ram; //!< how many bytes of textures are used.
extern int Bm_paging; //!< Bool type that indicates if BMPMAN is currently paging.
@@ -126,12 +113,7 @@ extern const BM_TYPE bm_ani_type_list[]; //!< List of valid bitmap animation t
extern const char *bm_ani_ext_list[]; //!< List of extensions for those types
extern const int BM_ANI_NUM_TYPES; //!< Calculated number of bitmap animation types
extern int GLOWMAP; //!< References a map that is a fully lit version of its index -Bobboau
extern int SPECMAP; //!< References a map that is for specular mapping -Bobboau
extern int ENVMAP; //!< References a map that is for environment mapping -Bobboau
extern int NORMMAP; //!< Normal mapping
extern int HEIGHTMAP; //!< Height map for normal mapping
extern int MISCMAP; //!< Utility map, to be utilized for various things shader authors can come up with
/**
* @brief Initilizes the bitmap manager
@@ -143,22 +125,6 @@ void bm_init();
*/
void bm_close();
/**
* Gets the cache slot of the bitmap indexed by handle.
*
* @details if the bitmap is an ani, gets the first frame
*
* @returns The cache slot index of the bitmap if handle is valid
*
* @note If the handle is invalid, an Assert() fails
*/
int bm_get_cache_slot(int bitmap_id, int separate_ani_frames);
/**
* @brief Gets the next available bitmap slot.
*/
int bm_get_next_handle();
#define BMP_FLAG_RENDER_TARGET_STATIC (1<<0)
#define BMP_FLAG_RENDER_TARGET_DYNAMIC (1<<1)
#define BMP_FLAG_CUBEMAP (1<<2)
@@ -196,9 +162,6 @@ public:
bool valid();
float get_channel_red(float u, float v);
float get_channel_green(float u, float v);
float get_channel_blue(float u, float v);
float get_channel_alpha(float u, float v);
};
@@ -340,13 +303,6 @@ int bm_load_either(const char *filename, int *nframes = NULL, int *fps = NULL, i
*/
bitmap* bm_lock(int handle, int bpp, ubyte flags, bool nodebug = false);
/**
* @brief Returns a unique signiature for the bitmap indexed by handle
*
* @details A signature will change when the bitmap's data changes
*/
uint bm_get_signature(int handle);
/**
* @brief Returns the image type of the given bitmap handle
*/
@@ -412,13 +368,6 @@ void bm_get_filename(int bitmapnum, char *filename);
*/
const char *bm_get_filename(int handle);
/**
* @brief Loads all data for all bitmaps that have been requested to be loaded
*
* @note This function is not defined.
*/
void bm_gfx_load_all();
/**
* @brief Unloads all used bitmaps, should only ever be called by game_shutdown()
*
@@ -437,15 +386,6 @@ void bm_unload_all();
*/
void bm_get_palette(int handle, ubyte *pal, char *name);
/**
* @brief Hack to get a pixel from a bitmap
*
* @details only works good in 8bpp mode
*
* @note This function is not defined.
*/
void bm_gfx_get_pixel(int bitmap, float u, float v, ubyte *r, ubyte *g, ubyte *b);
/**
* @brief (DEBUG) Gets memory size, in bytes, of the locked bitmaps
*
@@ -504,15 +444,6 @@ void bm_page_in_xparent_texture(int bitmapnum, int num_frames = 1);
*/
void bm_page_in_aabitmap(int bitmapnum, int num_frames = 1);
/**
* @brief Unloads the bitmap indexed by handle that was previously paged-in
*
* @returns 0 If the bitmap had already been released, or
* @returns 0 If the handle is invalid, or
* @returns 1 If successful
*/
bool bm_page_out(int handle);
/**
* @brief Sets BMPMAN's memory mode
*
@@ -561,16 +492,6 @@ void BM_SELECT_ALPHA_TEX_FORMAT();
*/
extern void(*bm_set_components)(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
/**
* @brief Functional pointer that references any of the bm_set_components_32 functions.
*
* @details The bm_set_components functions packs the RGBA values into the ubyte array referenced by pixel, whose
* format differs according to its bpp value and presence of an alpha channel. The RGBA values are scaled accordingly.
*
* @see bm_set_components
*/
extern void(*bm_set_components_32)(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
/**
* @brief Sets the 16bpp screen pixel to the specified RGBA value
*
@@ -578,13 +499,6 @@ extern void(*bm_set_components_32)(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, u
*/
void bm_set_components_argb_16_screen(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
/**
* @brief Sets the 32bpp screen pixel to the specified RGBA value
*
* @see bm_set_components
*/
void bm_set_components_argb_32_screen(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
/**
* @brief Sets the 16bpp texture pixel to the specified RGBA value
*
@@ -606,15 +520,7 @@ void bm_set_components_argb_32_tex(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, u
*/
void bm_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
extern int UNLITMAP; //this holds a reference to a map that is optional used instead of the base map for unlit rendering
extern int GLOWMAP; //this holds a reference to a map that is a fully lit version of its index -Bobboau
extern int SPECMAP; //this holds a reference to a map that is for specular mapping -Bobboau
extern int SPECGLOSSMAP; //this holds a reference to a map that is for specular mapping -Bobboau
extern int ENVMAP; //this holds a reference to a map that is for environment mapping -Bobboau
extern int NORMMAP; // normal mapping
extern int HEIGHTMAP; // height map for normal mapping
extern int AMBIENTMAP; // ambient occluion map. red channel affects ambient lighting, green channel affects diffuse and specular
extern int MISCMAP; // Utility map, to be utilized for various things shader authors can come up with
/**
* @brief Returns the compression type of the bitmap indexed by handle
@@ -626,10 +532,6 @@ int bm_is_compressed(int handle);
*/
int bm_get_tcache_type(int handle);
/**
* @brief Gets the size, in bytes, taken up by the bitmap indexed by handle
*/
size_t bm_get_size(int handle);
/**
* @brief Gets the number of mipmaps of the indexed texture
@@ -741,6 +643,18 @@ int bm_get_array_index(const int handle);
*/
int bmpman_count_bitmaps();
/**
* @brief Counts how many slots are available to the bmpman system
*
* Since the number of slots is dynamic now, this should be used for determining the total amount of available slots at
* the moment.
*
* @warning This is entirely for debugging and logging purposes. It should not be used in actual engine code.
*
* @return The number of available slots
*/
int bmpman_count_available_slots();
/**
* @brief Checks if the given filename is a valid effect or texture file name
*
+24 -18
View File
@@ -7,9 +7,10 @@
#include "math/vecmat.h"
#include "mod_table/mod_table.h"
#include "model/model.h" //polymodel, model_get
#include "options/Option.h"
#include "parse/parselo.h"
#include "playerman/player.h" //player_get_padlock_orient
#include "ship/ship.h" //compute_slew_matrix
#include "ship/ship.h" //compute_slew_matrix
//*************************IMPORTANT GLOBALS*************************
float VIEWER_ZOOM_DEFAULT = 0.75f; // Default viewer zoom, 0.625 as per multi-lateral agreement on 3/24/97
@@ -24,6 +25,23 @@ SCP_vector<camera*> Cameras;
camid Current_camera;
camid Main_camera;
static SCP_string fov_display(float val)
{
auto degrees = fl_degrees(val);
SCP_string out;
sprintf(out, u8"%.1f\u00B0", degrees);
return out;
}
auto FovOption = options::OptionBuilder<float>("Graphics.FOV", "Field Of View", "The vertical field of view.")
.category("Graphics")
.range(0.436332f, 1.5708f)
.bind_to(&VIEWER_ZOOM_DEFAULT)
.display(fov_display)
.default_val(0.75f)
.level(options::ExpertLevel::Advanced)
.importance(60)
.finish();
//*************************CLASS: camera*************************
//This is where the camera class beings! :D
camera::camera(const char *in_name, int in_signature)
@@ -145,7 +163,7 @@ void camera::set_object_target(object *objp, int n_object_target_submodel)
* Custom function receives the already-modified current position value.
* It should be replaced or added to as the custom function modifier sees fit.
*/
void camera::set_custom_position_function(void (*n_func_custom_position)(camera *cam, vec3d *camera_pos))
void camera::set_custom_position_function(void (*n_func_custom_position)(camera* /*cam*/, vec3d* /*camera_pos*/))
{
func_custom_position = n_func_custom_position;
}
@@ -154,7 +172,7 @@ void camera::set_custom_position_function(void (*n_func_custom_position)(camera
* Custom function receives the already-modified current orientation value.
* It should be replaced or added to as the custom function modifier sees fit.
*/
void camera::set_custom_orientation_function(void (*n_func_custom_orientation)(camera *cam, matrix *camera_ori))
void camera::set_custom_orientation_function(void (*n_func_custom_orientation)(camera* /*cam*/, matrix* /*camera_ori*/))
{
func_custom_orientation = n_func_custom_orientation;
}
@@ -185,13 +203,6 @@ void camera::set_position(vec3d *in_position, float in_translation_time, float i
pos_z.setAVD(in_position->xyz.z, in_translation_time, in_translation_acceleration_time, in_translation_deceleration_time, in_end_velocity);
}
void camera::set_translation_velocity(vec3d *in_velocity, float in_acceleration_time)
{
pos_x.setVD(in_acceleration_time, in_acceleration_time, in_velocity->xyz.x);
pos_y.setVD(in_acceleration_time, in_acceleration_time, in_velocity->xyz.y);
pos_z.setVD(in_acceleration_time, in_acceleration_time, in_velocity->xyz.z);
}
void camera::set_rotation(matrix *in_orientation, float in_rotation_time, float in_rotation_acceleration_time, float in_rotation_deceleration_time)
{
if(in_orientation != NULL && in_rotation_time == 0.0f && in_rotation_acceleration_time == 0.0f && in_rotation_deceleration_time == 0.0f)
@@ -245,12 +256,7 @@ void camera::set_rotation_facing(vec3d *in_target, float in_rotation_time, float
set_rotation(&temp_matrix, in_rotation_time, in_rotation_acceleration_time, in_rotation_deceleration_time);
}
void camera::set_rotation_velocity(angles *in_rotation_rate, float in_acceleration_time)
{
Error(LOCATION, "This function is disabled until further notice.");
}
void camera::do_frame(float in_frametime)
void camera::do_frame(float /*in_frametime*/)
{
}
@@ -802,7 +808,7 @@ void subtitle::clone(const subtitle &sub)
post_shaded = sub.post_shaded;
}
const subtitle &subtitle::operator=(const subtitle &sub)
subtitle& subtitle::operator=(const subtitle &sub)
{
if (this != &sub) {
if (image_id != -1) {
@@ -962,7 +968,7 @@ size_t cam_get_num()
/**
* Looks up camera by name, returns -1 on failure
*/
camid cam_lookup(char *name)
camid cam_lookup(const char* name)
{
size_t i, size=Cameras.size();
for(i = 0; i < size; i++)
+3 -6
View File
@@ -17,7 +17,6 @@
class camera
{
friend class avd_camera;
protected:
char name[NAME_LENGTH];
int sig;
@@ -60,15 +59,13 @@ public:
void set_fov(float in_fov, float in_fov_time = 0.0f, float in_fov_acceleration_time = 0.0f, float in_deceleration_time = 0.0f);
void set_position(vec3d *in_position = NULL, float in_translation_time = 0.0f, float in_translation_acceleration_time = 0.0f, float in_translation_deceleration_time = 0.0f, float in_end_velocity = 0.0f);
void set_translation_velocity(vec3d *in_velocity, float in_acceleration_time = 0.0f);
void set_rotation(matrix *in_orientation = NULL, float in_rotation_time = 0.0f, float in_rotation_acceleration_time = 0.0f, float in_rotation_deceleration_time = 0.0f);
void set_rotation(angles *in_angles, float in_rotation_time = 0.0f, float in_rotation_acceleration_time = 0.0f, float in_rotation_deceleration_time = 0.0f);
void set_rotation_facing(vec3d *in_target, float in_rotation_time = 0.0f, float in_rotation_acceleration_time = 0.0f, float in_rotation_deceleration_time = 0.0f);
void set_rotation_velocity(angles *in_rotation_rate, float in_acceleration_time = 0.0f);
//Get
char *get_name() {return name;}
const char* get_name() { return name; }
int get_signature() {return sig;}
object *get_object_host();
int get_object_host_submodel();
@@ -143,7 +140,7 @@ public:
~subtitle();
subtitle(const subtitle &sub) { clone(sub); }
const subtitle &operator=(const subtitle &sub);
subtitle& operator=(const subtitle &sub);
void do_frame(float frametime);
bool is_post_shaded( ) { return post_shaded; }
@@ -163,7 +160,7 @@ camid cam_create(const char *n_name, vec3d *n_pos, vec3d *n_norm, object *n_obje
void cam_delete(camid cid);
bool cam_set_camera(camid cid);
void cam_reset_camera();
camid cam_lookup(char *name);
camid cam_lookup(const char* name);
camid cam_get_camera(uint index);
camid cam_get_current();
size_t cam_get_num();
+204 -308
View File
@@ -10,10 +10,10 @@
#define _CFILE_INTERNAL
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cerrno>
#include <sys/stat.h>
#ifdef _WIN32
@@ -33,21 +33,21 @@
#include "cfile/cfilesystem.h"
#include "osapi/osapi.h"
#include "parse/encrypt.h"
#include "cfilesystem.h"
#include <limits>
char Cfile_root_dir[CFILE_ROOT_DIRECTORY_LEN] = "";
char Cfile_user_dir[CFILE_ROOT_DIRECTORY_LEN] = "";
#ifdef SCP_UNIX
char Cfile_user_dir_legacy[CFILE_ROOT_DIRECTORY_LEN] = "";
#endif
// During cfile_init, verify that Pathtypes[n].index == n for each item
// Each path must have a valid parent that can be tracable all the way back to the root
// Each path must have a valid parent that can be tracable all the way back to the root
// so that we can create directories when we need to.
//
// Please make sure extensions are all lower-case, or we'll break unix compatibility
//
// clang-format off
cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
// What type this is Path Extensions Parent type
{ CF_TYPE_INVALID, NULL, NULL, CF_TYPE_INVALID },
@@ -57,7 +57,7 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
{ CF_TYPE_MAPS, "data" DIR_SEPARATOR_STR "maps", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
{ CF_TYPE_TEXT, "data" DIR_SEPARATOR_STR "text", ".txt .net", CF_TYPE_DATA },
{ CF_TYPE_MODELS, "data" DIR_SEPARATOR_STR "models", ".pof", CF_TYPE_DATA },
{ CF_TYPE_TABLES, "data" DIR_SEPARATOR_STR "tables", ".tbl .tbm", CF_TYPE_DATA },
{ CF_TYPE_TABLES, "data" DIR_SEPARATOR_STR "tables", ".tbl .tbm .lua", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS, "data" DIR_SEPARATOR_STR "sounds", ".wav .ogg", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS_8B22K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "8b22k", ".wav .ogg", CF_TYPE_SOUNDS },
{ CF_TYPE_SOUNDS_16B11K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "16b11k", ".wav .ogg", CF_TYPE_SOUNDS },
@@ -69,7 +69,7 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
{ CF_TYPE_VOICE_SPECIAL, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "special", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_TRAINING, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "training", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_MUSIC, "data" DIR_SEPARATOR_STR "music", ".wav .ogg", CF_TYPE_DATA },
{ CF_TYPE_MOVIES, "data" DIR_SEPARATOR_STR "movies", ".mve .msb .ogg .mp4", CF_TYPE_DATA },
{ CF_TYPE_MOVIES, "data" DIR_SEPARATOR_STR "movies", ".mve .msb .ogg .mp4 .srt .webm .png",CF_TYPE_DATA },
{ CF_TYPE_INTERFACE, "data" DIR_SEPARATOR_STR "interface", ".pcx .ani .dds .tga .eff .png .jpg", CF_TYPE_DATA },
{ CF_TYPE_FONT, "data" DIR_SEPARATOR_STR "fonts", ".vf .ttf", CF_TYPE_DATA },
{ CF_TYPE_EFFECTS, "data" DIR_SEPARATOR_STR "effects", ".ani .eff .pcx .neb .tga .jpg .png .dds .sdr", CF_TYPE_DATA },
@@ -77,8 +77,8 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
{ CF_TYPE_PLAYERS, "data" DIR_SEPARATOR_STR "players", ".hcf", CF_TYPE_DATA },
{ CF_TYPE_PLAYER_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "images", ".pcx .png .dds", CF_TYPE_PLAYERS },
{ CF_TYPE_SQUAD_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "squads", ".pcx .png .dds", CF_TYPE_PLAYERS },
{ CF_TYPE_SINGLE_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "single", ".pl2 .cs2 .plr .csg .css", CF_TYPE_PLAYERS },
{ CF_TYPE_MULTI_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "multi", ".plr", CF_TYPE_PLAYERS },
{ CF_TYPE_SINGLE_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "single", ".pl2 .cs2 .plr .csg .css .json", CF_TYPE_PLAYERS },
{ CF_TYPE_MULTI_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "multi", ".plr .json", CF_TYPE_PLAYERS },
{ CF_TYPE_CACHE, "data" DIR_SEPARATOR_STR "cache", ".clr .tmp .bx", CF_TYPE_DATA }, //clr=cached color
{ CF_TYPE_MULTI_CACHE, "data" DIR_SEPARATOR_STR "multidata", ".pcx .png .dds .fs2 .txt", CF_TYPE_DATA },
{ CF_TYPE_MISSIONS, "data" DIR_SEPARATOR_STR "missions", ".fs2 .fc2 .ntl .ssv", CF_TYPE_DATA },
@@ -89,8 +89,10 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
{ CF_TYPE_SCRIPTS, "data" DIR_SEPARATOR_STR "scripts", ".lua .lc", CF_TYPE_DATA },
{ CF_TYPE_FICTION, "data" DIR_SEPARATOR_STR "fiction", ".txt", CF_TYPE_DATA },
{ CF_TYPE_FREDDOCS, "data" DIR_SEPARATOR_STR "freddocs", ".html", CF_TYPE_DATA },
{ CF_TYPE_INTERFACE_MARKUP, "data" DIR_SEPARATOR_STR "interface" DIR_SEPARATOR_STR "markup", ".rml", CF_TYPE_INTERFACE },
{ CF_TYPE_INTERFACE_CSS, "data" DIR_SEPARATOR_STR "interface" DIR_SEPARATOR_STR "css", ".rcss", CF_TYPE_INTERFACE },
};
// clang-format on
#define CFILE_STACK_MAX 8
@@ -99,8 +101,7 @@ static int Cfile_stack_pos = 0;
static char Cfile_stack[CFILE_STACK_MAX][CFILE_ROOT_DIRECTORY_LEN];
Cfile_block Cfile_block_list[MAX_CFILE_BLOCKS];
static CFILE Cfile_list[MAX_CFILE_BLOCKS];
std::array<CFILE, MAX_CFILE_BLOCKS> Cfile_block_list;
static const char *Cfile_cdrom_dir = NULL;
@@ -199,7 +200,6 @@ int cfile_init(const char *exe_dir, const char *cdrom_dir)
strncpy(buf, exe_dir, CFILE_ROOT_DIRECTORY_LEN - 1);
buf[CFILE_ROOT_DIRECTORY_LEN - 1] = '\0';
size_t i = strlen(buf);
// are we in a root directory?
if(cfile_in_root_dir(buf)){
@@ -224,18 +224,11 @@ int cfile_init(const char *exe_dir, const char *cdrom_dir)
cfile_chdir(buf);
// set root directory
strncpy(Cfile_root_dir, buf, CFILE_ROOT_DIRECTORY_LEN-1);
strncpy(Cfile_user_dir, os_get_config_path().c_str(), CFILE_ROOT_DIRECTORY_LEN-1);
#ifdef SCP_UNIX
// Initialize path of old pilot files
extern const char* Osreg_user_dir_legacy;
snprintf(Cfile_user_dir_legacy, CFILE_ROOT_DIRECTORY_LEN-1, "%s/%s/", getenv("HOME"), Osreg_user_dir_legacy);
#endif
strcpy_s(Cfile_root_dir, buf);
strcpy_s(Cfile_user_dir, os_get_config_path().c_str());
for (i = 0; i < MAX_CFILE_BLOCKS; i++) {
Cfile_block_list[i].type = CFILE_BLOCK_UNUSED;
}
// Initialize the block list with proper data
Cfile_block_list.fill({});
// 32 bit CRC table init
cf_chksum_long_init();
@@ -246,16 +239,6 @@ int cfile_init(const char *exe_dir, const char *cdrom_dir)
return 0;
}
// Call this if pack files got added or removed or the
// cdrom changed. This will refresh the list of filenames
// stored in packfiles and on the cdrom.
void cfile_refresh()
{
cf_build_secondary_filelist(Cfile_cdrom_dir);
}
#ifdef _WIN32
// Changes to a drive if valid.. 1=A, 2=B, etc
// If flag, then changes to it.
@@ -356,8 +339,7 @@ int cfile_push_chdir(int type)
return -1;
}
strncpy(Cfile_stack[Cfile_stack_pos++], OriginalDirectory,
CFILE_ROOT_DIRECTORY_LEN - 1);
strcpy_s(Cfile_stack[Cfile_stack_pos++], OriginalDirectory);
cf_create_default_path_string(dir, sizeof(dir) - 1, type, NULL);
@@ -467,7 +449,7 @@ char *cf_add_ext(const char *filename, const char *ext)
size_t elen = strlen(ext);
Assert(flen < MAX_PATH_LEN);
strcpy_s(path, filename);
if ((flen < 4) || stricmp(path + flen - elen, ext)) {
if ((flen < 4) || stricmp(path + flen - elen, ext) != 0) {
Assert(flen + elen < MAX_PATH_LEN);
strcat_s(path, ext);
}
@@ -480,17 +462,17 @@ char *cf_add_ext(const char *filename, const char *ext)
*
* @param filename Name of file to delete
* @param path_type Path type (CF_TYPE_xxx)
* @param location_flags Where to search for the location of the file to delete
*
* @return 0 on failure, 1 on success
*/
int cf_delete(const char *filename, int path_type)
int cf_delete(const char *filename, int path_type, uint32_t location_flags)
{
char longname[MAX_PATH_LEN];
Assert(CF_TYPE_SPECIFIED(path_type));
cf_create_default_path_string(longname, sizeof(longname) - 1,
path_type, filename);
cf_create_default_path_string(longname, sizeof(longname) - 1, path_type, filename, false, location_flags);
return (_unlink(longname) != -1);
}
@@ -516,12 +498,12 @@ int cf_access(const char *filename, int dir_type, int mode)
// If offset equates to boolean true, it was found in a VP and the logic will negate the function return
int cf_exists(const char *filename, int dir_type)
{
size_t offset = 1;
if ( (filename == NULL) || !strlen(filename) )
return 0;
return (cf_find_file_location(filename, dir_type, 0, NULL, NULL, &offset) && !offset);
auto find_res = cf_find_file_location(filename, dir_type);
return find_res.found && !find_res.offset;
}
// Goober5000
@@ -532,7 +514,7 @@ int cf_exists_full(const char *filename, int dir_type)
if ( (filename == NULL) || !strlen(filename) )
return 0;
return cf_find_file_location(filename, dir_type, 0, NULL, NULL, NULL);
return cf_find_file_location(filename, dir_type).found;
}
// same as the above, but with extension check
@@ -544,7 +526,7 @@ int cf_exists_full_ext(const char *filename, int dir_type, const int num_ext, co
if ( (num_ext <= 0) || (ext_list == NULL) )
return 0;
return (cf_find_file_location_ext(filename, num_ext, ext_list, dir_type, 0, NULL, NULL, NULL) != -1);
return cf_find_file_location_ext(filename, num_ext, ext_list, dir_type).found;
}
#ifdef _WIN32
@@ -561,7 +543,7 @@ void cf_attrib(const char *filename, int set, int clear, int dir_type)
fclose(fp);
DWORD z = GetFileAttributes(longname);
SetFileAttributes(longname, z | set & ~clear);
SetFileAttributes(longname, z | (set & ~clear));
}
}
@@ -618,7 +600,7 @@ static void mkdir_recursive(const char *path) {
// Creates the directory path if it doesn't exist. Even creates all its
// parent paths.
void cf_create_directory( int dir_type )
void cf_create_directory(int dir_type, uint32_t location_flags)
{
int num_dirs = 0;
int dir_tree[CF_MAX_PATH_TYPES];
@@ -640,7 +622,7 @@ void cf_create_directory( int dir_type )
int i;
for (i=num_dirs-1; i>=0; i-- ) {
cf_create_default_path_string( longname, sizeof(longname)-1, dir_tree[i], NULL );
cf_create_default_path_string(longname, sizeof(longname) - 1, dir_tree[i], nullptr, false, location_flags);
if (stat(longname, &statbuf) != 0) {
mprintf(( "CFILE: Creating new directory '%s'\n", longname ));
mkdir_recursive(longname);
@@ -648,9 +630,6 @@ void cf_create_directory( int dir_type )
}
}
extern int game_cd_changed();
// cfopen()
//
// parameters: *filepath ==> name of file to open (may be path+name)
@@ -667,14 +646,13 @@ extern int game_cd_changed();
// error ==> NULL
//
CFILE *_cfopen(const char* source, int line, const char *file_path, const char *mode, int type, int dir_type, bool localize)
CFILE* _cfopen(const char* source, int line, const char* file_path, const char* mode, int type, int dir_type,
bool localize, uint32_t location_flags)
{
/* Bobboau, what is this doing here? 31 is way too short... - Goober5000
if( strlen(file_path) > 31 )
Error(LOCATION, "file name %s too long, \nmust be less than 31 charicters", file_path);*/
char longname[_MAX_PATH];
if ( !cfile_inited ) {
Int3();
return NULL;
@@ -686,7 +664,7 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
Assert( mode != NULL );
// Can only open read-only binary files in memory mapped mode.
if ( (type & CFILE_MEMORY_MAPPED) && strcmp(mode,"rb") ) {
if ( (type & CFILE_MEMORY_MAPPED) && strcmp(mode,"rb") != 0 ) {
Int3();
return NULL;
}
@@ -696,6 +674,8 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
// the harddisk. No fancy packfile stuff here!
if ( strchr(mode,'w') || strchr(mode,'+') || strchr(mode,'a') ) {
char longname[_MAX_PATH];
// For write-only files, require a full path or a path type
#ifdef SCP_UNIX
if ( strpbrk(file_path, "/") ) {
@@ -709,9 +689,9 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
Assert( dir_type != CF_TYPE_ANY );
// Create the directory if necessary
cf_create_directory( dir_type );
cf_create_directory(dir_type, location_flags);
cf_create_default_path_string( longname, sizeof(longname)-1, dir_type, file_path );
cf_create_default_path_string(longname, sizeof(longname) - 1, dir_type, file_path, false, location_flags);
}
Assert( !(type & CFILE_MEMORY_MAPPED) );
@@ -761,30 +741,29 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
//================================================
// Search for file on disk, on cdrom, or in a packfile
size_t offset, size;
char copy_file_path[MAX_PATH_LEN]; // FIX change in memory from cf_find_file_location
strcpy_s(copy_file_path, file_path);
const void* file_data = nullptr;
if ( cf_find_file_location( copy_file_path, dir_type, sizeof(longname) - 1, longname, &size, &offset, localize, &file_data ) ) {
auto find_res = cf_find_file_location( copy_file_path, dir_type, localize, location_flags );
if ( find_res.found ) {
// Fount it, now create a cfile out of it
nprintf(("CFileDebug", "Requested file %s found at: %s\n", file_path, longname));
nprintf(("CFileDebug", "Requested file %s found at: %s\n", file_path, find_res.full_name.c_str()));
if ( type & CFILE_MEMORY_MAPPED ) {
// Can't open memory mapped files out of pack or memory files
if ( offset == 0 && file_data != nullptr ) {
if ( find_res.offset == 0 && find_res.data_ptr != nullptr ) {
#if defined _WIN32
HANDLE hFile;
hFile = CreateFile(longname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
hFile = CreateFile(find_res.full_name.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
return cf_open_mapped_fill_cfblock(source, line, hFile, dir_type);
}
#elif defined SCP_UNIX
FILE *fp = fopen( longname, "rb" );
FILE* fp = fopen(find_res.full_name.c_str(), "rb");
if (fp) {
return cf_open_mapped_fill_cfblock(source, line, fp, dir_type);
}
@@ -793,7 +772,8 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
} else {
// since cfopen_special already has all the code to handle the opening we can just use that here
return _cfopen_special(source, line, longname, mode, size, offset, file_data, dir_type);
return _cfopen_special(source, line, find_res.full_name.c_str(), mode, find_res.size, find_res.offset,
find_res.data_ptr, dir_type);
}
}
@@ -882,14 +862,14 @@ CFILE *ctmpfile()
static int cfget_cfile_block()
{
int i;
Cfile_block *cb;
CFILE* cfile;
for ( i = 0; i < MAX_CFILE_BLOCKS; i++ ) {
cb = &Cfile_block_list[i];
if ( cb->type == CFILE_BLOCK_UNUSED ) {
cb->data = NULL;
cb->fp = NULL;
cb->type = CFILE_BLOCK_USED;
cfile = &Cfile_block_list[i];
if (cfile->type == CFILE_BLOCK_UNUSED) {
cfile->data = nullptr;
cfile->fp = nullptr;
cfile->type = CFILE_BLOCK_USED;
return i;
}
}
@@ -901,7 +881,7 @@ static int cfget_cfile_block()
mprintf(("Out of cfile blocks! Currently opened files:\n"));
dump_opened_files();
Assertion(false, "There are no more free cfile blocks. This means that there are too many files opened by FSO.\n"
UNREACHABLE("There are no more free cfile blocks. This means that there are too many files opened by FSO.\n"
"This is probably caused by a programming or scripting error where a file does not get closed."); // out of free cfile blocks
return -1;
}
@@ -917,39 +897,36 @@ int cfclose( CFILE * cfile )
int result;
Assert(cfile != NULL);
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
result = 0;
if ( cb->data && cb->mem_mapped ) {
if ( cfile->data && cfile->mem_mapped ) {
// close memory mapped file
#if defined _WIN32
result = UnmapViewOfFile((void*)cb->data);
result = UnmapViewOfFile((void*)cfile->data);
Assert(result);
result = CloseHandle(cb->hInFile);
result = CloseHandle(cfile->hInFile);
Assert(result); // Ensure file handle is closed properly
result = CloseHandle(cb->hMapFile);
result = CloseHandle(cfile->hMapFile);
Assert(result); // Ensure file handle is closed properly
result = 0;
#elif defined SCP_UNIX
// FIXME: result is wrong after munmap() but it is successful
//result = munmap(cb->data, cb->data_length);
//result = munmap(cfile->data, cfile->data_length);
//Assert(result);
// This const_cast is safe since the pointer returned by mmap was also non-const
munmap(const_cast<void*>(cb->data), cb->data_length);
if ( cb->fp != NULL)
result = fclose(cb->fp);
munmap(const_cast<void*>(cfile->data), cfile->data_length);
if ( cfile->fp != nullptr)
result = fclose(cfile->fp);
#endif
} else if ( cb->fp != NULL ) {
Assert(cb->fp != NULL);
result = fclose(cb->fp);
} else if ( cfile->fp != nullptr ) {
Assert(cfile->fp != nullptr);
result = fclose(cfile->fp);
} else {
// VP do nothing
}
cb->type = CFILE_BLOCK_UNUSED;
cfile->type = CFILE_BLOCK_UNUSED;
return result;
}
@@ -959,13 +936,8 @@ int cf_is_valid(CFILE *cfile)
if(cfile == NULL)
return 0;
//Does it have a valid ID?
if(cfile->id < 0 || cfile->id >= MAX_CFILE_BLOCKS)
return 0;
//Is it used?
Cfile_block *cb = &Cfile_block_list[cfile->id];
if(cb->type != CFILE_BLOCK_USED && (cb->fp != NULL || cb->data != NULL))
if (cfile->type != CFILE_BLOCK_USED && (cfile->fp != nullptr || cfile->data != nullptr))
return 0;
//It's good, as near as we can tell.
@@ -990,20 +962,15 @@ static CFILE *cf_open_fill_cfblock(const char* source, int line, FILE *fp, int t
fclose(fp);
return NULL;
} else {
CFILE *cfp;
Cfile_block *cfbp;
cfbp = &Cfile_block_list[cfile_block_index];
cfp = &Cfile_list[cfile_block_index];
cfp->id = cfile_block_index;
cfp->version = 0;
cfbp->data = NULL;
cfbp->mem_mapped = false;
cfbp->fp = fp;
cfbp->dir_type = type;
cfbp->max_read_len = 0;
CFILE *cfp = &Cfile_block_list[cfile_block_index];
cfp->data = nullptr;
cfp->mem_mapped = false;
cfp->fp = fp;
cfp->dir_type = type;
cfp->max_read_len = 0;
cfbp->source_file = source;
cfbp->line_num = line;
cfp->source_file = source;
cfp->line_num = line;
int pos = ftell(fp);
if(pos == -1L)
@@ -1031,21 +998,16 @@ static CFILE *cf_open_packed_cfblock(const char* source, int line, FILE *fp, int
fclose(fp);
return NULL;
} else {
CFILE *cfp;
Cfile_block *cfbp;
cfbp = &Cfile_block_list[cfile_block_index];
cfp = &Cfile_list[cfile_block_index];
cfp->id = cfile_block_index;
cfp->version = 0;
cfbp->data = NULL;
cfbp->fp = fp;
cfbp->mem_mapped = false;
cfbp->dir_type = type;
cfbp->max_read_len = 0;
CFILE *cfp = &Cfile_block_list[cfile_block_index];
cfbp->source_file = source;
cfbp->line_num = line;
cfp->data = nullptr;
cfp->fp = fp;
cfp->mem_mapped = false;
cfp->dir_type = type;
cfp->max_read_len = 0;
cfp->source_file = source;
cfp->line_num = line;
cf_init_lowlevel_read_code(cfp,offset, size, 0 );
@@ -1077,44 +1039,39 @@ static CFILE *cf_open_mapped_fill_cfblock(const char* source, int line, FILE *fp
return NULL;
}
else {
CFILE *cfp;
Cfile_block *cfbp;
cfbp = &Cfile_block_list[cfile_block_index];
CFILE *cfp = &Cfile_block_list[cfile_block_index];
cfp = &Cfile_list[cfile_block_index];
cfp->id = cfile_block_index;
cfp->version = 0;
cfbp->max_read_len = 0;
cfbp->fp = NULL;
cfbp->mem_mapped = true;
cfp->max_read_len = 0;
cfp->fp = nullptr;
cfp->mem_mapped = true;
#if defined _WIN32
cfbp->hInFile = hFile;
cfp->hInFile = hFile;
#endif
cfbp->dir_type = type;
cfp->dir_type = type;
cfbp->source_file = source;
cfbp->line_num = line;
cfp->source_file = source;
cfp->line_num = line;
cf_init_lowlevel_read_code(cfp, 0, 0, 0 );
#if defined _WIN32
cfbp->hMapFile = CreateFileMapping(cfbp->hInFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (cfbp->hMapFile == NULL) {
cfp->hMapFile = CreateFileMapping(cfp->hInFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (cfp->hMapFile == NULL) {
nprintf(("Error", "Could not create file-mapping object.\n"));
return NULL;
}
cfbp->data = (ubyte*)MapViewOfFile(cfbp->hMapFile, FILE_MAP_READ, 0, 0, 0);
Assert( cfbp->data != NULL );
cfp->data = (ubyte*)MapViewOfFile(cfp->hMapFile, FILE_MAP_READ, 0, 0, 0);
Assert( cfp->data != NULL );
#elif defined SCP_UNIX
cfbp->fp = fp;
cfbp->data_length = filelength( fileno(fp) );
cfbp->data = mmap(NULL, // start
cfbp->data_length, // length
PROT_READ, // prot
MAP_SHARED, // flags
fileno(fp), // fd
0); // offset
Assert( cfbp->data != NULL );
cfp->fp = fp;
cfp->data_length = filelength(fileno(fp));
cfp->data = mmap(nullptr, // start
cfp->data_length, // length
PROT_READ, // prot
MAP_SHARED, // flags
fileno(fp), // fd
0); // offset
Assert(cfp->data != nullptr);
#endif
return cfp;
@@ -1130,23 +1087,18 @@ static CFILE *cf_open_memory_fill_cfblock(const char* source, int line, const vo
return NULL;
}
else {
CFILE *cfp;
Cfile_block *cfbp;
cfbp = &Cfile_block_list[cfile_block_index];
CFILE *cfp = &Cfile_block_list[cfile_block_index];
cfp = &Cfile_list[cfile_block_index];
cfp->id = cfile_block_index;
cfp->version = 0;
cfbp->max_read_len = 0;
cfbp->fp = NULL;
cfbp->mem_mapped = false;
cfbp->dir_type = dir_type;
cfp->max_read_len = 0;
cfp->fp = nullptr;
cfp->mem_mapped = false;
cfp->dir_type = dir_type;
cfbp->source_file = source;
cfbp->line_num = line;
cfp->source_file = source;
cfp->line_num = line;
cf_init_lowlevel_read_code(cfp, 0, size, 0 );
cfbp->data = data;
cfp->data = data;
return cfp;
}
@@ -1154,7 +1106,7 @@ static CFILE *cf_open_memory_fill_cfblock(const char* source, int line, const vo
int cf_get_dir_type(CFILE *cfile)
{
return Cfile_block_list[cfile->id].dir_type;
return cfile->dir_type;
}
// cf_returndata() returns the data pointer for a memory-mapped file that is associated
@@ -1165,22 +1117,8 @@ int cf_get_dir_type(CFILE *cfile)
const void *cf_returndata(CFILE *cfile)
{
Assert(cfile != NULL);
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
Assert(cb->data != NULL);
return cb->data;
}
// version number of opened file. Will be 0 unless you put something else here after you
// open a file. Once set, you can use minimum version numbers with the read functions.
void cf_set_version( CFILE * cfile, int version )
{
Assert(cfile != NULL);
cfile->version = version;
Assert(cfile->data != nullptr);
return cfile->data;
}
// cutoff point where cfread() will throw an error when it hits this limit
@@ -1188,27 +1126,21 @@ void cf_set_version( CFILE * cfile, int version )
void cf_set_max_read_len( CFILE * cfile, size_t len )
{
Assert( cfile != NULL );
Assert( (cfile->id >= 0) && (cfile->id < MAX_CFILE_BLOCKS) );
Cfile_block *cb = &Cfile_block_list[cfile->id];
if (len) {
cb->max_read_len = cb->raw_position + len;
cfile->max_read_len = cfile->raw_position + len;
} else {
cb->max_read_len = 0;
cfile->max_read_len = 0;
}
}
// routines to read basic data types from CFILE's. Put here to
// simplify mac/pc reading from cfiles.
float cfread_float(CFILE *file, int ver, float deflt)
float cfread_float(CFILE* file, float deflt)
{
float f;
if (file->version < ver)
return deflt;
if (cfread( &f, sizeof(f), 1, file) != 1)
return deflt;
@@ -1216,13 +1148,10 @@ float cfread_float(CFILE *file, int ver, float deflt)
return f;
}
int cfread_int(CFILE *file, int ver, int deflt)
int cfread_int(CFILE* file, int deflt)
{
int i;
if (file->version < ver)
return deflt;
if (cfread( &i, sizeof(i), 1, file) != 1)
return deflt;
@@ -1230,13 +1159,10 @@ int cfread_int(CFILE *file, int ver, int deflt)
return i;
}
uint cfread_uint(CFILE *file, int ver, uint deflt)
uint cfread_uint(CFILE* file, uint deflt)
{
uint i;
if (file->version < ver)
return deflt;
if (cfread( &i, sizeof(i), 1, file) != 1)
return deflt;
@@ -1244,13 +1170,10 @@ uint cfread_uint(CFILE *file, int ver, uint deflt)
return i;
}
short cfread_short(CFILE *file, int ver, short deflt)
short cfread_short(CFILE* file, short deflt)
{
short s;
if (file->version < ver)
return deflt;
if (cfread( &s, sizeof(s), 1, file) != 1)
return deflt;
@@ -1258,13 +1181,10 @@ short cfread_short(CFILE *file, int ver, short deflt)
return s;
}
ushort cfread_ushort(CFILE *file, int ver, ushort deflt)
ushort cfread_ushort(CFILE* file, ushort deflt)
{
ushort s;
if (file->version < ver)
return deflt;
if (cfread( &s, sizeof(s), 1, file) != 1)
return deflt;
@@ -1272,58 +1192,26 @@ ushort cfread_ushort(CFILE *file, int ver, ushort deflt)
return s;
}
ubyte cfread_ubyte(CFILE *file, int ver, ubyte deflt)
ubyte cfread_ubyte(CFILE* file, ubyte deflt)
{
ubyte b;
if (file->version < ver)
return deflt;
if (cfread( &b, sizeof(b), 1, file) != 1)
return deflt;
return b;
}
void cfread_vector(vec3d *vec, CFILE *file, int ver, vec3d *deflt)
{
if (file->version < ver) {
if (deflt)
*vec = *deflt;
else
vec->xyz.x = vec->xyz.y = vec->xyz.z = 0.0f;
return;
}
vec->xyz.x = cfread_float(file, ver, deflt ? deflt->xyz.x : 0.0f);
vec->xyz.y = cfread_float(file, ver, deflt ? deflt->xyz.y : 0.0f);
vec->xyz.z = cfread_float(file, ver, deflt ? deflt->xyz.z : 0.0f);
}
void cfread_angles(angles *ang, CFILE *file, int ver, angles *deflt)
{
if (file->version < ver) {
if (deflt)
*ang = *deflt;
else
ang->p = ang->b = ang->h = 0.0f;
return;
}
ang->p = cfread_float(file, ver, deflt ? deflt->p : 0.0f);
ang->b = cfread_float(file, ver, deflt ? deflt->b : 0.0f);
ang->h = cfread_float(file, ver, deflt ? deflt->h : 0.0f);
void cfread_vector(vec3d* vec, CFILE* file, vec3d* deflt) {
vec->xyz.x = cfread_float(file, deflt ? deflt->xyz.x : 0.0f);
vec->xyz.y = cfread_float(file, deflt ? deflt->xyz.y : 0.0f);
vec->xyz.z = cfread_float(file, deflt ? deflt->xyz.z : 0.0f);
}
char cfread_char(CFILE *file, int ver, char deflt)
char cfread_char(CFILE* file, char deflt)
{
char b;
if (file->version < ver)
return deflt;
if (cfread( &b, sizeof(b), 1, file) != 1)
return deflt;
@@ -1354,6 +1242,19 @@ void cfread_string_len(char *buf,int n, CFILE *file)
buf[len] = 0;
}
SCP_string cfread_string_len(CFILE *file)
{
int len = cfread_int(file);
SCP_string str;
str.resize(len);
if (len)
cfread(&str[0], len, 1, file);
return str;
}
// equivalent write functions of above read functions follow
int cfwrite_float(float f, CFILE *file)
@@ -1391,28 +1292,6 @@ int cfwrite_ubyte(ubyte b, CFILE *file)
return cfwrite(&b, sizeof(b), 1, file);
}
int cfwrite_vector(vec3d *vec, CFILE *file)
{
if(!cfwrite_float(vec->xyz.x, file)){
return 0;
}
if(!cfwrite_float(vec->xyz.y, file)){
return 0;
}
return cfwrite_float(vec->xyz.z, file);
}
int cfwrite_angles(angles *ang, CFILE *file)
{
if(!cfwrite_float(ang->p, file)){
return 0;
}
if(!cfwrite_float(ang->b, file)){
return 0;
}
return cfwrite_float(ang->h, file);
}
int cfwrite_char(char b, CFILE *file)
{
return cfwrite( &b, sizeof(b), 1, file);
@@ -1445,22 +1324,18 @@ int cfwrite_string_len(const char *buf, CFILE *file)
}
// Get the filelength
int cfilelength( CFILE * cfile )
{
int cfilelength(CFILE* cfile) {
Assert(cfile != NULL);
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
// TODO: return length of memory mapped file
Assert( !cb->mem_mapped );
Assert(!cfile->mem_mapped);
// cfile->size gets set at cfopen
// cb->size gets set at cfopen
// The rest of the code still uses ints, do an overflow check to detect cases where this fails
Assertion(cb->size <= static_cast<size_t>(std::numeric_limits<int>::max()),
"Integer overflow in cfilelength! A file is too large (but I don't know which...).");
return (int) cb->size;
Assertion(cfile->size <= static_cast<size_t>(std::numeric_limits<int>::max()),
"Integer overflow in cfilelength! A file is too large (but I don't know which...).");
return (int) cfile->size;
}
// cfwrite() writes to the file
@@ -1476,15 +1351,13 @@ int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile)
if(buf == NULL || elsize == 0 || nelem == 0)
return 0;
Cfile_block *cb = &Cfile_block_list[cfile->id];
if(cb->lib_offset != 0)
if(cfile->lib_offset != 0)
{
Error(LOCATION, "Attempt to write to a VP file (unsupported)");
return 0;
}
if(cb->data != NULL)
if(cfile->data != nullptr)
{
Warning(LOCATION, "Writing is not supported for mem-mapped files");
return EOF;
@@ -1493,16 +1366,16 @@ int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile)
size_t bytes_written = 0;
size_t size = elsize * nelem;
bytes_written = fwrite(buf, 1, size, cb->fp);
bytes_written = fwrite(buf, 1, size, cfile->fp);
//WMC - update filesize and position
if (bytes_written > 0) {
cb->size += bytes_written;
cb->raw_position += bytes_written;
cfile->size += bytes_written;
cfile->raw_position += bytes_written;
}
#if defined(CHECK_SIZE) && !defined(NDEBUG)
Assert( cb->size == filelength(fileno(cb->fp)) );
Assert( cfile->size == filelength(fileno(cfile->fp)) );
#endif
return (int)(bytes_written / elsize);
@@ -1519,34 +1392,32 @@ int cfputc(int c, CFILE *cfile)
if(!cf_is_valid(cfile))
return EOF;
Cfile_block *cb = &Cfile_block_list[cfile->id];
if(cb->lib_offset != 0)
if(cfile->lib_offset != 0)
{
Error(LOCATION, "Attempt to write character to a VP file (unsupported)");
return EOF;
}
if(cb->data != NULL)
if(cfile->data != nullptr)
{
Warning(LOCATION, "Writing is not supported for mem-mapped files");
return EOF;
}
// writing not supported for memory-mapped files
Assert( !cb->data );
Assert( !cfile->data );
int result = fputc(c, cb->fp);
int result = fputc(c, cfile->fp);
//WMC - update filesize and position
if(result != EOF)
{
cb->size += 1;
cb->raw_position += 1;
cfile->size += 1;
cfile->raw_position += 1;
}
#if defined(CHECK_SIZE) && !defined(NDEBUG)
Assert( cb->size == filelength(fileno(cb->fp)) );
Assert( cfile->size == filelength(fileno(cfile->fp)) );
#endif
return result;
@@ -1565,31 +1436,29 @@ int cfputs(const char *str, CFILE *cfile)
if(str == NULL)
return EOF;
Cfile_block *cb = &Cfile_block_list[cfile->id];
if(cb->lib_offset != 0)
if(cfile->lib_offset != 0)
{
Error(LOCATION, "Attempt to write character to a VP file (unsupported)");
return EOF;
}
if(cb->data != NULL)
if(cfile->data != nullptr)
{
Warning(LOCATION, "Writing is not supported for mem-mapped files");
return EOF;
}
int result = fputs(str, cb->fp);
int result = fputs(str, cfile->fp);
//WMC - update filesize and position
if(result != EOF)
{
cb->size += strlen(str);
cb->raw_position += strlen(str);
cfile->size += strlen(str);
cfile->raw_position += strlen(str);
}
#if defined(CHECK_SIZE) && !defined(NDEBUG)
Assert( cb->size == filelength(fileno(cb->fp)) );
Assert( cfile->size == filelength(fileno(cfile->fp)) );
#endif
return result;
@@ -1951,19 +1820,46 @@ int cf_chksum_long(CFILE *file, uint *chksum, int max_size)
int cflush(CFILE *cfile)
{
Assert(cfile != NULL);
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
// not supported for memory mapped files
Assert( !cb->data );
Assert( !cfile->data );
Assert(cb->fp != NULL);
Assert(cfile->fp != nullptr);
int result = fflush(cb->fp);
int result = fflush(cfile->fp);
//WMC - update filesize
cb->size = filelength(fileno(cb->fp));
cfile->size = filelength(fileno(cfile->fp));
return result;
}
int cfile_get_path_type(const SCP_string& dir)
{
SCP_string buf = dir;
// Remove trailing slashes; avoid buffer overflow on 1-char strings
while (buf.size() > 0 && (buf[buf.size() - 1] == '\\' || buf[buf.size() - 1] == '/')) {
buf.resize(buf.size() - 1);
}
// Remove leading slashes
while (buf.size() > 0 && (buf[0] == '\\' || buf[0] == '/')) {
buf = buf.substr(1);
}
// Use official DIR_SEPARATOR_CHAR
for (char& c : buf) {
if (c == '\\' || c == '/') {
c = DIR_SEPARATOR_CHAR;
}
}
for (auto& Pathtype : Pathtypes) {
if (Pathtype.path != nullptr && buf == Pathtype.path) {
return Pathtype.index;
}
}
return CF_TYPE_INVALID;
}
+133 -48
View File
@@ -13,10 +13,11 @@
#define __CFILE_H__
#include <ctime>
#include "globalincs/pstypes.h"
#include <ctime>
#include <stdexcept>
#include <memory>
#define CF_EOF (-1)
@@ -25,10 +26,8 @@
#define CF_SEEK_CUR (1)
#define CF_SEEK_END (2)
typedef struct CFILE {
int id; // Index into cfile.cpp specific structure
int version; // version of this file
} CFILE;
// Opaque file handle
struct CFILE;
// extra info that can be returned when getting a file listing
typedef struct {
@@ -79,9 +78,11 @@ typedef struct {
#define CF_TYPE_SCRIPTS 35
#define CF_TYPE_FICTION 36
#define CF_TYPE_FREDDOCS 37
#define CF_TYPE_INTERFACE_MARKUP 38
#define CF_TYPE_INTERFACE_CSS 39
#define CF_MAX_PATH_TYPES 38 // Can be as high as you'd like //DTP; yeah but beware alot of things uses CF_MAX_PATH_TYPES
#define CF_MAX_PATH_TYPES \
40 // Can be as high as you'd like //DTP; yeah but beware alot of things uses CF_MAX_PATH_TYPES
// TRUE if type is specified and valid
#define CF_TYPE_SPECIFIED(path_type) (((path_type)>CF_TYPE_INVALID) && ((path_type)<CF_MAX_PATH_TYPES))
@@ -95,8 +96,63 @@ typedef struct {
#define CF_SORT_TIME 2
#define CF_SORT_REVERSE 3
#define cfread_fix(file) (fix)cfread_int(file)
#define cfwrite_fix(i,file) cfwrite_int(i,file)
/**
* @brief Contains a collection of flags for specifying from where a CFILE should be opened
*
* There are two types of flags. CF_LOCATION_GAME_ROOT and CF_LOCATION_USER_ROOT specify in which basic root directory
* CFile should search for files.
*
* The remaining flags control what type of location may be used for the operation. It's possible to restrict the
* location to the primary mod, the remaining mods or the top-level root directory.
*/
enum CFileLocationFlags {
CF_LOCATION_ROOT_GAME = 1 << 0, //!< The game root location. This is the location of the game data (e.g. FS2 retail)
/**
* @brief The user directories.
*
* If the engine is in portable mode then using this flag exclusively will result in a failure to open files!
*/
CF_LOCATION_ROOT_USER = 1 << 1,
/**
* @brief The memory root
*
* This contains all the built-in files available to the engine.
*/
CF_LOCATION_ROOT_MEMORY = 1 << 2,
/**
* @brief Mask for extracting root type from a location bit field
*/
CF_LOCATION_ROOT_MASK = 0xFFFF,
CF_LOCATION_TYPE_ROOT = 1 << 16, //!< The basic, top-level root location
/**
* @brief The primary mod location.
*
* This is the mod that appears first on the command line. If there are no mods then the root location is considered
* to be the primary mod
*/
CF_LOCATION_TYPE_PRIMARY_MOD = 1 << 17,
/**
* @brief The remaining mods.
*
* If there are no mods on the command line then this might not include any valid location.
*/
CF_LOCATION_TYPE_SECONDARY_MODS = 1 << 18,
/**
* @brief Bitmask for extracting the type from a location bit field
*/
CF_LOCATION_TYPE_MASK = 0xFFFF0000,
/**
* @brief A combination of all flags
*
* This should be used when the default behavior without any location filtering is desired.
*/
CF_LOCATION_ALL = CF_LOCATION_ROOT_MASK | CF_LOCATION_TYPE_MASK
};
// callback function used for get_file_list() to filter files to be added to list. Return 1
// to add file to list, or 0 to not add it.
@@ -111,30 +167,21 @@ extern const char *Get_file_list_child;
#define CFILE_ROOT_DIRECTORY_LEN 256
extern char Cfile_root_dir[CFILE_ROOT_DIRECTORY_LEN];
extern char Cfile_user_dir[CFILE_ROOT_DIRECTORY_LEN];
#ifdef SCP_UNIX
extern char Cfile_user_dir_legacy[CFILE_ROOT_DIRECTORY_LEN];
#endif
//================= LOW-LEVEL FUNCTIONS ==================
int cfile_init(const char *exe_dir, const char *cdrom_dir=NULL);
void cfile_close();
// Call this if pack files got added or removed or the
// cdrom changed. This will refresh the list of filenames
// stored in packfiles and on the cdrom.
void cfile_refresh();
// add an extension to a filename if it doesn't already have it
char *cf_add_ext(const char *filename, const char *ext);
// return CF_TYPE (directory location type) of a CFILE you called cfopen() successfully on.
int cf_get_dir_type(CFILE *cfile);
// Opens the file. If no path is given, use the extension to look into the
// default path. If mode is NULL, delete the file.
CFILE *_cfopen(const char* source_file, int line, const char *filename, const char *mode,
int type = CFILE_NORMAL, int dir_type = CF_TYPE_ANY, bool localize = false);
// default path. If mode is NULL, delete the file.
CFILE* _cfopen(const char* source_file, int line, const char* filename, const char* mode, int type = CFILE_NORMAL,
int dir_type = CF_TYPE_ANY, bool localize = false, uint32_t location_flags = CF_LOCATION_ALL);
#define cfopen(...) _cfopen(LOCATION, __VA_ARGS__) // Pass source location to the function
// like cfopen(), but it accepts a fully qualified path only (ie, the result of a cf_find_file_location() call)
@@ -146,17 +193,13 @@ CFILE *_cfopen_special(const char* source_file, int line, const char *file_path,
// Flush the open file buffer
int cflush(CFILE *cfile);
// version number of opened file. Will be 0 unless you put something else here after you
// open a file. Once set, you can use minimum version numbers with the read functions.
void cf_set_version( CFILE * cfile, int version );
// will throw an error if cfread*() functions read past this mark
// converted to raw offsets when used, but gets passed actual length from current position
// setting 'len' to zero will disable the check
void cf_set_max_read_len(CFILE *cfile, size_t len);
// Deletes a file. Returns 0 on error, 1 if successful
int cf_delete(const char *filename, int dir_type);
int cf_delete(const char *filename, int dir_type, uint32_t location_flags = CF_LOCATION_ALL);
// Same as _access function to read a file's access bits
int cf_access(const char *filename, int dir_type, int mode);
@@ -190,10 +233,6 @@ int cfread(void *buf, int elsize, int nelem, CFILE *fp);
// cfwrite() writes to the file
int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile);
// Reads/writes RLE compressed data.
int cfread_compressed(void *buf, int elsize, int nelem, CFILE *cfile);
int cfwrite_compressed(void *param_buf, int param_elsize, int param_nelem, CFILE *cfile);
// Moves the file pointer
int cfseek(CFILE *fp, int offset, int where);
@@ -245,7 +284,6 @@ uint cf_add_chksum_long(uint seed, ubyte *buffer, size_t size);
// convenient for misc checksumming purposes ------------------------------------------
//================= HIGH LEVEL FUNCTIONS ==================
int cfexist(const char *filename); // Returns true if file exists on disk (1) or in hog (2).
// rename a file, utilizing the extension to determine where file is.
#define CF_RENAME_SUCCESS 0 // successfully renamed the file
@@ -253,6 +291,10 @@ int cfexist(const char *filename); // Returns true if file exists on disk (1) or
#define CF_RENAME_FAIL_EXIST 2 // old name does not exist
int cf_rename(const char *old_name, const char *name, int type = CF_TYPE_ANY );
// Creates the directory path if it doesn't exist. Even creates all its
// parent paths.
void cf_create_directory(int dir_type, uint32_t location_flags = CF_LOCATION_ALL);
// changes the attributes of a file
void cf_attrib(const char *name, int set, int clear, int type);
@@ -263,17 +305,15 @@ int cfile_flush_dir(int type);
// functions for reading from cfile
// These are all high level, built up from
// cfread.
int cfgetc(CFILE *fp);
char *cfgets(char *buf, size_t n, CFILE *fp);
char cfread_char(CFILE *file, int ver = 0, char deflt = 0);
ubyte cfread_ubyte(CFILE *file, int ver = 0, ubyte deflt = 0);
short cfread_short(CFILE *file, int ver = 0, short deflt = 0);
ushort cfread_ushort(CFILE *file, int ver = 0, ushort deflt = 0);
int cfread_int(CFILE *file, int ver = 0, int deflt = 0);
uint cfread_uint(CFILE *file, int ver = 0, uint deflt = 0);
float cfread_float(CFILE *file, int ver = 0, float deflt = 0.0f);
void cfread_vector(vec3d *vec, CFILE *file, int ver = 0, vec3d *deflt = NULL);
void cfread_angles(angles *ang, CFILE *file, int ver = 0, angles *deflt = NULL);
char cfread_char(CFILE* file, char deflt = 0);
ubyte cfread_ubyte(CFILE* file, ubyte deflt = 0);
short cfread_short(CFILE* file, short deflt = 0);
ushort cfread_ushort(CFILE* file, ushort deflt = 0);
int cfread_int(CFILE* file, int deflt = 0);
uint cfread_uint(CFILE* file, uint deflt = 0);
float cfread_float(CFILE* file, float deflt = 0.0f);
void cfread_vector(vec3d* vec, CFILE* file, vec3d* deflt = nullptr);
// Reads variable length, null-termined string. Will only read up
// to n characters.
@@ -289,6 +329,13 @@ void cfread_string(char *buf,int n, CFILE *file);
*/
void cfread_string_len(char *buf,int n, CFILE *file);
/**
* @brief Read a string from the file where the length is stored in the file
* @param file The file to read the string from
* @return The string that was read
*/
SCP_string cfread_string_len(CFILE *file);
// functions for writing cfiles
int cfwrite_char(char c, CFILE *file);
int cfwrite_float(float f, CFILE *file);
@@ -297,8 +344,6 @@ int cfwrite_uint(uint i, CFILE *file);
int cfwrite_short(short s, CFILE *file);
int cfwrite_ushort(ushort s, CFILE *file);
int cfwrite_ubyte(ubyte u, CFILE *file);
int cfwrite_vector(vec3d *vec, CFILE *file);
int cfwrite_angles(angles *ang, CFILE *file);
// writes variable length, null-termined string.
int cfwrite_string(const char *buf, CFILE *file);
@@ -311,12 +356,26 @@ int cfwrite_string(const char *buf, CFILE *file);
*/
int cfwrite_string_len(const char *buf, CFILE *file);
int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *filter, int sort = CF_SORT_NONE, SCP_vector<file_list_info> *info = NULL );
int cf_get_file_list( int max, char **list, int type, const char *filter, int sort = CF_SORT_NONE, file_list_info *info = NULL );
int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char **list, int type, const char *filter, int sort = CF_SORT_NONE, file_list_info *info = NULL );
int cf_get_file_list(SCP_vector<SCP_string>& list, int pathtype, const char* filter, int sort = CF_SORT_NONE,
SCP_vector<file_list_info>* info = nullptr, uint32_t location_flags = CF_LOCATION_ALL);
int cf_get_file_list(int max, char** list, int type, const char* filter, int sort = CF_SORT_NONE,
file_list_info* info = nullptr, uint32_t location_flags = CF_LOCATION_ALL);
int cf_get_file_list_preallocated(int max, char arr[][MAX_FILENAME_LEN], char** list, int type, const char* filter,
int sort = CF_SORT_NONE, file_list_info* info = nullptr,
uint32_t location_flags = CF_LOCATION_ALL);
void cf_sort_filenames( int n, char **list, int sort, file_list_info *info = NULL );
void cf_sort_filenames( SCP_vector<SCP_string> &list, int sort, SCP_vector<file_list_info> *info = NULL );
struct CFileLocation {
bool found = false;
SCP_string full_name;
size_t size = 0;
size_t offset = 0;
const void* data_ptr = nullptr;
explicit CFileLocation(bool found_in = false) : found(found_in) {}
};
// Searches for a file. Follows all rules and precedence and searches
// CD's and pack files.
// Input: filespace - Filename & extension
@@ -326,7 +385,17 @@ void cf_sort_filenames( SCP_vector<SCP_string> &list, int sort, SCP_vector<file_
// size - File size
// offset - Offset into pack file. 0 if not a packfile.
// Returns: If not found returns 0.
int cf_find_file_location( const char *filespec, int pathtype, int max_out, char *pack_filename, size_t *size, size_t *offset, bool localize = false, const void** data_out = nullptr);
CFileLocation cf_find_file_location(const char* filespec, int pathtype, bool localize = false,
uint32_t location_flags = CF_LOCATION_ALL);
struct CFileLocationExt : public CFileLocation {
int extension_index = -1;
explicit CFileLocationExt(int extension_index_in = -1)
: CFileLocation(extension_index_in >= 0), extension_index(extension_index_in)
{
}
};
// Searches for a file. Follows all rules and precedence and searches
// CD's and pack files. Searches all locations in order for first filename using ext filter list.
@@ -340,7 +409,8 @@ int cf_find_file_location( const char *filespec, int pathtype, int max_out, char
// offset - Offset into pack file. 0 if not a packfile.
// Returns: If not found returns -1, else returns offset into ext_list.
// (NOTE: This function is exponentially slow, so don't use it unless truely needed!!)
int cf_find_file_location_ext(const char *filename, const int ext_num, const char **ext_list, int pathtype, int max_out = 0, char *pack_filename = NULL, size_t *size = NULL, size_t *offset = NULL, bool localize = false, const void** data_out = nullptr);
CFileLocationExt cf_find_file_location_ext(const char* filename, const int ext_num, const char** ext_list, int pathtype,
bool localize = false);
// Functions to change directories
int cfile_chdir(const char *dir);
@@ -355,6 +425,8 @@ int cfile_push_chdir(int type);
// restore directory on top of the stack
int cfile_pop_dir();
int cfile_get_path_type(const SCP_string& dir);
namespace cfile
{
// exceptions and other errors
@@ -393,4 +465,17 @@ namespace cfile
}
// This allows to use std::unique_ptr with CFILE
namespace std {
template <>
struct default_delete<CFILE> {
void operator()(CFILE* ptr)
{
if (cf_is_valid(ptr)) {
cfclose(ptr);
}
}
};
} // namespace std
#endif /* __CFILE_H__ */
+58 -77
View File
@@ -11,9 +11,9 @@
#define _CFILE_INTERNAL
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#ifdef _WIN32
#include <io.h>
@@ -36,24 +36,20 @@
void cf_init_lowlevel_read_code( CFILE * cfile, size_t lib_offset, size_t size, size_t pos )
{
Assert(cfile != NULL);
Assert(cfile != nullptr);
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
cfile->lib_offset = lib_offset;
cfile->raw_position = pos;
cfile->size = size;
cb->lib_offset = lib_offset;
cb->raw_position = pos;
cb->size = size;
if ( cb->fp ) {
if ( cb->lib_offset ) {
fseek( cb->fp, (long)cb->lib_offset, SEEK_SET );
if ( cfile->fp ) {
if ( cfile->lib_offset ) {
fseek( cfile->fp, (long)cfile->lib_offset, SEEK_SET );
}
#if defined(CHECK_POSITION) && !defined(NDEBUG)
auto raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
auto raw_position = ftell(cfile->fp) - cfile->lib_offset;
Assert(raw_position == cfile->raw_position);
#endif
}
}
@@ -70,20 +66,16 @@ int cfeof(CFILE *cfile)
{
Assert(cfile != NULL);
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
int result = 0;
#if defined(CHECK_POSITION) && !defined(NDEBUG)
if (cb->fp) {
auto raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
if (cfile->fp) {
auto raw_position = ftell(cfile->fp) - cfile->lib_offset;
Assert(raw_position == cfile->raw_position);
}
#endif
if (cb->raw_position >= cb->size ) {
if (cfile->raw_position >= cfile->size ) {
result = 1;
} else {
result = 0;
@@ -100,21 +92,18 @@ int cfeof(CFILE *cfile)
int cftell( CFILE * cfile )
{
Assert(cfile != NULL);
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
#if defined(CHECK_POSITION) && !defined(NDEBUG)
if (cb->fp) {
auto raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
if (cfile->fp) {
auto raw_position = ftell(cfile->fp) - cfile->lib_offset;
Assert(raw_position == cfile->raw_position);
}
#endif
// The rest of the code still uses ints, do an overflow check to detect cases where this fails
Assertion(cb->raw_position <= static_cast<size_t>(std::numeric_limits<int>::max()),
Assertion(cfile->raw_position <= static_cast<size_t>(std::numeric_limits<int>::max()),
"Integer overflow in cftell, a file is probably too large (but I don't know which one).");
return (int) cb->raw_position;
return (int) cfile->raw_position;
}
@@ -127,27 +116,23 @@ int cfseek( CFILE *cfile, int offset, int where )
{
Assert(cfile != NULL);
Cfile_block *cb;
Assert(cfile->id >= 0 && cfile->id < MAX_CFILE_BLOCKS);
cb = &Cfile_block_list[cfile->id];
// TODO: seek to offset in memory mapped file
Assert( !cb->mem_mapped );
Assert( !cfile->mem_mapped );
size_t goal_position;
switch( where ) {
case CF_SEEK_SET:
goal_position = offset+cb->lib_offset;
goal_position = offset+cfile->lib_offset;
break;
case CF_SEEK_CUR:
{
goal_position = cb->raw_position+offset+cb->lib_offset;
goal_position = cfile->raw_position+offset+cfile->lib_offset;
}
break;
case CF_SEEK_END:
goal_position = cb->size+offset+cb->lib_offset;
goal_position = cfile->size+offset+cfile->lib_offset;
break;
default:
Int3();
@@ -155,23 +140,23 @@ int cfseek( CFILE *cfile, int offset, int where )
}
// Make sure we don't seek beyond the end of the file
CAP(goal_position, cb->lib_offset, cb->lib_offset + cb->size);
CAP(goal_position, cfile->lib_offset, cfile->lib_offset + cfile->size);
int result = 0;
if (cb->fp) {
if (cfile->fp) {
// If we have a file pointer we can also seek in that file
result = fseek(cb->fp, (long)goal_position, SEEK_SET );
Assertion(goal_position >= cb->lib_offset, "Invalid offset values detected while seeking! Goal was " SIZE_T_ARG ", lib_offset is " SIZE_T_ARG ".", goal_position, cb->lib_offset);
result = fseek(cfile->fp, (long)goal_position, SEEK_SET );
Assertion(goal_position >= cfile->lib_offset, "Invalid offset values detected while seeking! Goal was " SIZE_T_ARG ", lib_offset is " SIZE_T_ARG ".", goal_position, cfile->lib_offset);
}
// If we only have a data pointer this will do all the work
cb->raw_position = goal_position - cb->lib_offset;
Assertion(cb->raw_position <= cb->size, "Invalid raw_position value detected!");
cfile->raw_position = goal_position - cfile->lib_offset;
Assertion(cfile->raw_position <= cfile->size, "Invalid raw_position value detected!");
#if defined(CHECK_POSITION) && !defined(NDEBUG)
if (cb->fp) {
auto tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset == cb->raw_position);
if (cfile->fp) {
auto tmp_offset = ftell(cfile->fp) - cfile->lib_offset;
Assert(tmp_offset == cfile->raw_position);
}
#endif
@@ -194,19 +179,17 @@ int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
if(buf == NULL || size <= 0)
return 0;
Cfile_block *cb = &Cfile_block_list[cfile->id];
if ( (cb->raw_position+size) > cb->size ) {
Assertion(cb->raw_position <= cb->size, "Invalid raw_position value detected!");
size = cb->size - cb->raw_position;
if ( (cfile->raw_position+size) > cfile->size ) {
Assertion(cfile->raw_position <= cfile->size, "Invalid raw_position value detected!");
size = cfile->size - cfile->raw_position;
if ( size < 1 ) {
return 0;
}
//mprintf(( "CFILE: EOF encountered in file\n" ));
}
if (cb->max_read_len) {
if ( cb->raw_position+size > cb->max_read_len ) {
if (cfile->max_read_len) {
if ( cfile->raw_position+size > cfile->max_read_len ) {
std::ostringstream s_buf;
s_buf << "Attempted to read " << size << "-byte(s) beyond length limit";
@@ -215,22 +198,22 @@ int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
}
size_t bytes_read;
if (cb->data != nullptr) {
if (cfile->data != nullptr) {
// This is a file from memory
bytes_read = size;
memcpy(buf, reinterpret_cast<const char*>(cb->data) + cb->raw_position, size);
memcpy(buf, reinterpret_cast<const char*>(cfile->data) + cfile->raw_position, size);
} else {
bytes_read = fread( buf, 1, size, cb->fp );
bytes_read = fread( buf, 1, size, cfile->fp );
}
if ( bytes_read > 0 ) {
cb->raw_position += bytes_read;
Assertion(cb->raw_position <= cb->size, "Invalid raw_position value detected!");
cfile->raw_position += bytes_read;
Assertion(cfile->raw_position <= cfile->size, "Invalid raw_position value detected!");
}
#if defined(CHECK_POSITION) && !defined(NDEBUG)
if (cb->fp) {
auto tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
if (cfile->fp) {
auto tmp_offset = ftell(cfile->fp) - cfile->lib_offset;
Assert(tmp_offset==cfile->raw_position);
}
#endif
@@ -246,10 +229,8 @@ int cfread_lua_number(double *buf, CFILE *cfile)
if(buf == NULL)
return 0;
Cfile_block *cb = &Cfile_block_list[cfile->id];
// cfread() not supported for memory-mapped files
if(cb->data != NULL)
if(cfile->data != nullptr)
{
Warning(LOCATION, "Writing is not supported for mem-mapped files");
return 0;
@@ -257,28 +238,28 @@ int cfread_lua_number(double *buf, CFILE *cfile)
size_t advance = 0;
int items_read;
if (cb->fp) {
long orig_pos = ftell(cb->fp);
items_read = fscanf(cb->fp, LUA_NUMBER_SCAN, buf);
advance = (size_t) (ftell(cb->fp)-orig_pos);
if (cfile->fp) {
long orig_pos = ftell(cfile->fp);
items_read = fscanf(cfile->fp, LUA_NUMBER_SCAN, buf);
advance = (size_t) (ftell(cfile->fp)-orig_pos);
} else {
int read;
// %n returns the number of bytes currently read so we append that to the scan format at the end so it will return
// how many bytes we have consumed
items_read = sscanf(reinterpret_cast<const char*>(cb->data), LUA_NUMBER_SCAN "%n", buf, &read);
items_read = sscanf(reinterpret_cast<const char*>(cfile->data), LUA_NUMBER_SCAN "%n", buf, &read);
if (items_read == 2) {
// We need to correct the items read counter since we read one additional item
items_read = 1;
}
advance = (size_t) read;
}
cb->raw_position += advance;
Assertion(cb->raw_position <= cb->size, "Invalid raw_position value detected!");
cfile->raw_position += advance;
Assertion(cfile->raw_position <= cfile->size, "Invalid raw_position value detected!");
#if defined(CHECK_POSITION) && !defined(NDEBUG)
if (cb->fp) {
auto tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
if (cfile->fp) {
auto tmp_offset = ftell(cfile->fp) - cfile->lib_offset;
Assert(tmp_offset==cfile->raw_position);
}
#endif
+14 -15
View File
@@ -22,31 +22,30 @@
#define CFILE_BLOCK_UNUSED 0
#define CFILE_BLOCK_USED 1
typedef struct Cfile_block {
int type; // CFILE_BLOCK_UNUSED, CFILE_BLOCK_USED
int dir_type; // directory location
FILE *fp; // File pointer if opening an individual file
const void *data; // Pointer for memory-mapped file access. NULL if not mem-mapped.
bool mem_mapped; // Flag for memory mapped files (if data is not null and this is false it means that it's an embedded file)
struct CFILE {
int type = CFILE_BLOCK_UNUSED; // CFILE_BLOCK_UNUSED, CFILE_BLOCK_USED
int dir_type; // directory location
FILE* fp; // File pointer if opening an individual file
const void* data; // Pointer for memory-mapped file access. NULL if not mem-mapped.
bool mem_mapped; // Flag for memory mapped files (if data is not null and this is false it means that it's an embedded file)
#ifdef _WIN32
HANDLE hInFile; // Handle from CreateFile()
HANDLE hMapFile; // Handle from CreateFileMapping()
#else
// int fd; // file descriptor
size_t data_length; // length of data for mmap
size_t data_length; // length of data for mmap
#endif
size_t lib_offset;
size_t raw_position;
size_t size; // for packed files
size_t lib_offset;
size_t raw_position;
size_t size; // for packed files
size_t max_read_len; // max read offset, for special error handling
size_t max_read_len; // max read offset, for special error handling
const char* source_file;
int line_num;
} Cfile_block;
};
#define MAX_CFILE_BLOCKS 64
extern Cfile_block Cfile_block_list[MAX_CFILE_BLOCKS];
extern std::array<CFILE, MAX_CFILE_BLOCKS> Cfile_block_list;
// Called once to setup the low-level reading code.
void cf_init_lowlevel_read_code( CFILE * cfile, size_t lib_offset, size_t size, size_t pos );
+4 -353
View File
@@ -9,9 +9,9 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>
@@ -200,353 +200,4 @@ void cf_sort_filenames( int n, char **list, int sort, file_list_info *info )
}
nprintf(("Error", "Unknown sorting method %d passed to cf_sort_filenames()\n", sort));
}
#if (0) // these aren't used anywhere now
// cf_compress - Do Run Length Compression on a block of data. Targa format.
//
// Usage:
// out Buffer to write it out to
// in Buffer to compress
// bytecount Number of bytes input
int cf_compress(char *out, char *in, int bytecount )
{
int pixcount; // number of pixels in the current packet
char *inputpixel=NULL; // current input pixel position
char *matchpixel=NULL; // pixel value to match for a run
char *flagbyte=NULL; // location of last flag byte to set
int rlcount; // current count in r.l. string
int rlthresh; // minimum valid run length
char *copyloc; // location to begin copying at
// set the threshold -- the minimum valid run length
rlthresh = 2; // Require a 2 pixel span before rle'ing
// set the first pixel up
flagbyte = out; // place to put next flag if run
inputpixel = in;
pixcount = 1;
rlcount = 0;
copyloc = (char *)0;
// loop till data processing complete
do {
// if we have accumulated a 128-byte packet, process it
if ( pixcount == 129 ) {
*flagbyte = 127;
// set the run flag if this is a run
if ( rlcount >= rlthresh ) {
*flagbyte |= 0x80;
pixcount = 2;
}
// copy the data into place
++flagbyte;
memmove( flagbyte, copyloc, pixcount-1 );
flagbyte += pixcount-1;
pixcount = 1;
// set up for next packet
continue;
}
// if zeroth byte, handle as special case
if ( pixcount == 1 ) {
rlcount = 0;
copyloc = inputpixel; /* point to 1st guy in packet */
matchpixel = inputpixel; /* set pointer to pix to match */
pixcount = 2;
inputpixel += 1;
continue;
}
// assembling a packet -- look at next pixel
// current pixel == match pixel?
if ( *inputpixel == *matchpixel ) {
// establishing a run of enough length to
// save space by doing it
// -- write the non-run length packet
// -- start run-length packet
if ( ++rlcount == rlthresh ) {
// close a non-run packet
if ( pixcount > (rlcount+1) ) {
// write out length and do not set run flag
*flagbyte++ = (char)(pixcount - 2 - rlthresh);
memmove(flagbyte, copyloc, (pixcount-1-rlcount) );
flagbyte += (pixcount-1-rlcount);
copyloc = inputpixel;
pixcount = rlcount + 1;
}
}
} else {
// no match -- either break a run or continue without one
// if a run exists break it:
// write the bytes in the string (1+1)
// start the next string
if ( rlcount >= rlthresh ) {
*flagbyte++ = (char)(0x80 | rlcount);
memmove(flagbyte, copyloc, 1 );
flagbyte += 1;
pixcount = 1;
continue;
} else {
// not a match and currently not a run
// - save the current pixel
// - reset the run-length flag
rlcount = 0;
matchpixel = inputpixel;
}
}
pixcount++;
inputpixel += 1;
} while ( inputpixel < (in + bytecount));
// quit this buffer without loosing any data
if ( --pixcount >= 1 ) {
*flagbyte = (char)(pixcount - 1);
if ( rlcount >= rlthresh ) {
*flagbyte |= 0x80;
pixcount = 1;
}
// copy the data into place
++flagbyte;
memmove(flagbyte, copyloc, pixcount );
flagbyte += pixcount;
}
return(flagbyte-out);
}
// cf_decompress - Do Decompression on a run-length encoded block of data. Targa format.
//
// Usage:
// out Buffer to write it out to
// in Buffer to compress
// bytecount Number of bytes input
int cf_decompress(char *out, char *in )
{
int count;
char *param_out = out;
while(1) {
count = int(*in++);
int run_span = count & 0x80;
count &= (~0x80);
if ( count > 0 ) {
if ( run_span ) {
// RLE'd data
ubyte c = *in++;
memset( out, c, count );
out += count;
} else {
memmove( out, in, count );
in += count;
out += count;
}
}
}
return out - param_out;
}
#endif // 0
// cfread() reads from a file and decompresses it
//
// returns: returns the number of full elements read
//
//
int cfread_compressed(void *buf, int elsize, int nelem, CFILE *cfile)
{
char *out = (char *)buf;
while(1) {
ubyte count;
if ( cfread( &count, 1, 1, cfile ) != 1 ) {
break;
}
int run_span = count & 0x80;
count &= (~0x80);
count++;
if ( count > 0 ) {
if ( run_span ) {
// RLE'd data
ubyte c;
if ( cfread( &c, 1, 1, cfile ) != 1 ) {
break;
}
memset( out, c, count );
} else {
if ( cfread( out, 1, count, cfile ) != count ) {
break;
}
}
out += count;
if ( out >= (char *)buf + (elsize*nelem)) {
break;
}
} else {
break;
}
}
return (int)((out - (char *)buf)/elsize);
}
int cfwrite_compressed(void *param_buf, int param_elsize, int param_nelem, CFILE *cfile)
{
char *in = (char *)param_buf;
int bytecount = (param_elsize * param_nelem );
int pixcount; // number of pixels in the current packet
char *inputpixel=NULL; // current input pixel position
char *matchpixel=NULL; // pixel value to match for a run
int rlcount; // current count in r.l. string
int rlthresh; // minimum valid run length
char *copyloc; // location to begin copying at
// set the threshold -- the minimum valid run length
rlthresh = 2; // Require a 2 pixel span before rle'ing
// set the first pixel up
inputpixel = in;
pixcount = 1;
rlcount = 0;
copyloc = (char *)0;
// loop till data processing complete
do {
// if we have accumulated a 128-byte packet, process it
if ( pixcount == 129 ) {
ubyte code = 127;
// set the run flag if this is a run
if ( rlcount >= rlthresh ) {
code |= 0x80;
pixcount = 2;
}
cfwrite( &code, 1, 1, cfile );
// copy the data into place
cfwrite( copyloc, 1, pixcount-1, cfile );
pixcount = 1;
// set up for next packet
continue;
}
// if zeroth byte, handle as special case
if ( pixcount == 1 ) {
rlcount = 0;
copyloc = inputpixel; /* point to 1st guy in packet */
matchpixel = inputpixel; /* set pointer to pix to match */
pixcount = 2;
inputpixel += 1;
continue;
}
// assembling a packet -- look at next pixel
// current pixel == match pixel?
if ( *inputpixel == *matchpixel ) {
// establishing a run of enough length to
// save space by doing it
// -- write the non-run length packet
// -- start run-length packet
if ( ++rlcount == rlthresh ) {
// close a non-run packet
if ( pixcount > (rlcount+1) ) {
// write out length and do not set run flag
ubyte code = (ubyte)(pixcount - 2 - rlthresh);
cfwrite( &code, 1, 1, cfile );
cfwrite( copyloc, 1, (pixcount-1-rlcount), cfile );
copyloc = inputpixel;
pixcount = rlcount + 1;
}
}
} else {
// no match -- either break a run or continue without one
// if a run exists break it:
// write the bytes in the string (1+1)
// start the next string
if ( rlcount >= rlthresh ) {
ubyte code = (ubyte)(0x80 | rlcount);
cfwrite( &code, 1, 1, cfile );
cfwrite( copyloc, 1, 1, cfile );
pixcount = 1;
continue;
} else {
// not a match and currently not a run
// - save the current pixel
// - reset the run-length flag
rlcount = 0;
matchpixel = inputpixel;
}
}
pixcount++;
inputpixel += 1;
} while ( inputpixel < (in + bytecount));
// quit this buffer without loosing any data
if ( --pixcount >= 1 ) {
ubyte code = ubyte(pixcount - 1);
// set the run flag if this is a run
if ( rlcount >= rlthresh ) {
code |= 0x80;
pixcount = 1;
}
cfwrite( &code, 1, 1, cfile );
// copy the data into place
cfwrite( copyloc, 1, pixcount, cfile );
}
return param_nelem;
}
}
+303 -220
View File
@@ -9,10 +9,10 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cerrno>
#include <sstream>
#include <algorithm>
@@ -48,9 +48,6 @@ enum CfileRootType {
CF_ROOTTYPE_MEMORY = 2,
};
// for a defined and specifically set location to get/send pilot/campaign files
SCP_string Pilot_file_path;
// Created by:
// specifying hard drive tree
// searching for pack files on hard drive // Found by searching all known paths
@@ -59,6 +56,7 @@ SCP_string Pilot_file_path;
typedef struct cf_root {
char path[CF_MAX_PATHNAME_LENGTH]; // Contains something like c:\projects\freespace or c:\projects\freespace\freespace.vp
int roottype; // CF_ROOTTYPE_PATH = Path, CF_ROOTTYPE_PACK =Pack file, CF_ROOTTYPE_MEMORY=In memory
uint32_t location_flags;
} cf_root;
// convenient type for sorting (see cf_build_pack_list())
@@ -347,9 +345,9 @@ void cf_build_pack_list( cf_root *root )
std::sort(temp_roots_sort, temp_roots_sort + temp_root_count, cf_packfile_sort_func);
// now insert them all into the real root list properly
cf_root *new_root;
for (i = 0; i < temp_root_count; i++) {
new_root = cf_create_root();
auto new_root = cf_create_root();
new_root->location_flags = root->location_flags;
strcpy_s( new_root->path, root->path );
#ifndef NDEBUG
@@ -378,10 +376,11 @@ static char normalize_directory_separator(char in)
return in;
}
static void cf_add_mod_roots(const char* rootDirectory)
static void cf_add_mod_roots(const char* rootDirectory, uint32_t basic_location)
{
if (Cmdline_mod)
{
bool primary = true;
for (const char* cur_pos=Cmdline_mod; strlen(cur_pos) != 0; cur_pos+= (strlen(cur_pos)+1))
{
SCP_stringstream ss;
@@ -405,9 +404,16 @@ static void cf_add_mod_roots(const char* rootDirectory)
cf_root* root = cf_create_root();
strncpy(root->path, rootPath.c_str(), CF_MAX_PATHNAME_LENGTH-1);
if (primary) {
root->location_flags = basic_location | CF_LOCATION_TYPE_PRIMARY_MOD;
} else {
root->location_flags = basic_location | CF_LOCATION_TYPE_SECONDARY_MODS;
}
root->roottype = CF_ROOTTYPE_PATH;
cf_build_pack_list(root);
primary = false;
}
}
}
@@ -425,10 +431,16 @@ void cf_build_root_list(const char *cdrom_dir)
#ifdef WIN32
// Nothing to do here, Windows uses the current directory as the base
#else
cf_add_mod_roots(Cfile_user_dir_legacy);
cf_add_mod_roots(os_get_legacy_user_dir(), CF_LOCATION_ROOT_USER);
root = cf_create_root();
strncpy(root->path, Cfile_user_dir_legacy, CF_MAX_PATHNAME_LENGTH - 1);
strncpy(root->path, os_get_legacy_user_dir(), CF_MAX_PATHNAME_LENGTH - 1);
root->location_flags |= CF_LOCATION_ROOT_USER | CF_LOCATION_TYPE_ROOT;
if (Cmdline_mod == nullptr || strlen(Cmdline_mod) <= 0) {
// If there are no mods then the root is the primary mod
root->location_flags |= CF_LOCATION_TYPE_PRIMARY_MOD;
}
// do we already have a slash? as in the case of a root directory install
if ((strlen(root->path) < (CF_MAX_PATHNAME_LENGTH - 1)) && (root->path[strlen(root->path) - 1] != DIR_SEPARATOR_CHAR)) {
@@ -436,10 +448,6 @@ void cf_build_root_list(const char *cdrom_dir)
}
root->roottype = CF_ROOTTYPE_PATH;
// If it wasn't set before, set the pilot path
if (Pilot_file_path.empty())
Pilot_file_path = root->path;
// Next, check any VP files under the current directory.
cf_build_pack_list(root);
#endif
@@ -449,13 +457,19 @@ void cf_build_root_list(const char *cdrom_dir)
{
// =========================================================================
// now look for mods under the users HOME directory to use before system ones
cf_add_mod_roots(Cfile_user_dir);
cf_add_mod_roots(Cfile_user_dir, CF_LOCATION_ROOT_USER);
// =========================================================================
// =========================================================================
// set users HOME directory as default for loading and saving files
root = cf_create_root();
strncpy(root->path, Cfile_user_dir, CF_MAX_PATHNAME_LENGTH - 1);
strcpy_s(root->path, Cfile_user_dir);
root->location_flags |= CF_LOCATION_ROOT_USER | CF_LOCATION_TYPE_ROOT;
if (Cmdline_mod == nullptr || strlen(Cmdline_mod) <= 0) {
// If there are no mods then the root is the primary mod
root->location_flags |= CF_LOCATION_TYPE_PRIMARY_MOD;
}
// do we already have a slash? as in the case of a root directory install
if ((strlen(root->path) < (CF_MAX_PATHNAME_LENGTH - 1)) && (root->path[strlen(root->path) - 1] != DIR_SEPARATOR_CHAR)) {
@@ -463,10 +477,6 @@ void cf_build_root_list(const char *cdrom_dir)
}
root->roottype = CF_ROOTTYPE_PATH;
// set the default player location to here
if (Pilot_file_path.empty())
Pilot_file_path = root->path;
// Next, check any VP files under the current directory.
cf_build_pack_list(root);
// =========================================================================
@@ -477,11 +487,17 @@ void cf_build_root_list(const char *cdrom_dir)
if ( !_getcwd(working_directory, CF_MAX_PATHNAME_LENGTH ) ) {
Error(LOCATION, "Can't get current working directory -- %d", errno );
}
cf_add_mod_roots(working_directory);
cf_add_mod_roots(working_directory, CF_LOCATION_ROOT_GAME);
root = cf_create_root();
root->location_flags |= CF_LOCATION_ROOT_GAME | CF_LOCATION_TYPE_ROOT;
if (Cmdline_mod == nullptr || strlen(Cmdline_mod) <= 0) {
// If there are no mods then the root is the primary mod
root->location_flags |= CF_LOCATION_TYPE_PRIMARY_MOD;
}
strcpy_s(root->path, working_directory);
size_t path_len = strlen(root->path);
@@ -493,10 +509,6 @@ void cf_build_root_list(const char *cdrom_dir)
root->roottype = CF_ROOTTYPE_PATH;
// If the path wasn't set before use the working directory
if ( Pilot_file_path.empty() )
Pilot_file_path = root->path;
//======================================================
// Next, check any VP files under the current directory.
cf_build_pack_list(root);
@@ -517,6 +529,7 @@ void cf_build_root_list(const char *cdrom_dir)
// The final root is the in-memory root
root = cf_create_root();
root->location_flags = CF_LOCATION_ROOT_MEMORY | CF_LOCATION_TYPE_ROOT;
memset(root->path, 0, sizeof(root->path));
root->roottype = CF_ROOTTYPE_MEMORY;
@@ -543,17 +556,40 @@ void cf_search_root_path(int root_index)
int i;
int num_files = 0;
cf_root *root = cf_get_root(root_index);
cf_root* root = cf_get_root(root_index);
mprintf(( "Searching root '%s' ... ", root->path ));
mprintf(("Searching root '%s' ... ", root->path));
#ifndef WIN32
try {
auto current = root->path;
const auto prefPathEnd = root->path + strlen(root->path);
while (current != prefPathEnd) {
const auto cp = utf8::next(current, prefPathEnd);
if (cp > 127) {
// On Windows, we currently do not support Unicode paths so catch this early and let the user
// know
const auto invalid_end = current;
utf8::prior(current, root->path);
Error(LOCATION,
"Trying to use path \"%s\" as a data root. That path is not supported since it "
"contains a Unicode character (%s). If possible, change this path to something that only uses "
"ASCII characters.",
root->path, std::string(current, invalid_end).c_str());
}
}
} catch (const std::exception& e) {
Error(LOCATION, "UTF-8 error while checking the root path \"%s\": %s", root->path, e.what());
}
#endif
char search_path[CF_MAX_PATHNAME_LENGTH];
#ifdef SCP_UNIX
// This map stores the mapping between a specific path type and the actual path that we use for it
// This map stores the mapping between a specific path type and the actual path that we use for it
SCP_unordered_map<int, SCP_string> pathTypeToRealPath;
#endif
for (i=CF_TYPE_ROOT; i<CF_MAX_PATH_TYPES; i++ ) {
for (i = CF_TYPE_ROOT; i < CF_MAX_PATH_TYPES; i++) {
// we don't want to add player files to the cache - taylor
if ( (i == CF_TYPE_SINGLE_PLAYERS) || (i == CF_TYPE_MULTI_PLAYERS) ) {
@@ -649,7 +685,7 @@ void cf_search_root_path(int root_index)
struct dirent *dir = nullptr;
while ((dir = readdir (parentDirP)) != nullptr) {
if (stricmp(search_name, dir->d_name)) {
if (stricmp(search_name, dir->d_name) != 0) {
continue;
}
@@ -977,15 +1013,12 @@ void cf_free_secondary_filelist()
*
* @param filespec Filename & extension
* @param pathtype See CF_TYPE_ defines in CFILE.H
* @param max_out Maximum string length that should be stuffed into pack_filename
* @param pack_filename OUTPUT: Absolute path and filename of this file. Could be a packfile or the actual file.
* @param size OUTPUT: File size
* @param offset OUTPUT: Offset into pack file. 0 if not a packfile.
* @param localize Undertake localization
* @param location_flags Specifies where to search for the specified flag
*
* @return If not found returns 0.
* @return A structure which describes the found file
*/
int cf_find_file_location( const char *filespec, int pathtype, int max_out, char *pack_filename, size_t *size, size_t *offset, bool localize, const void** data_out )
CFileLocation cf_find_file_location(const char* filespec, int pathtype, bool localize, uint32_t location_flags)
{
int i;
uint ui;
@@ -993,7 +1026,6 @@ int cf_find_file_location( const char *filespec, int pathtype, int max_out, char
char longname[MAX_PATH_LEN];
Assert( (filespec != NULL) && (strlen(filespec) > 0) ); //-V805
Assert( (pack_filename == NULL) || (max_out > 1) );
// see if we have something other than just a filename
// our current rules say that any file that specifies a direct
@@ -1009,16 +1041,15 @@ int cf_find_file_location( const char *filespec, int pathtype, int max_out, char
#endif
FILE *fp = fopen(filespec, "rb" );
if (fp) {
if ( size ) *size = filelength(fileno(fp));
if ( offset ) *offset = 0;
if ( pack_filename ) {
strncpy( pack_filename, filespec, max_out );
}
CFileLocation res(true);
res.size = static_cast<size_t>(filelength(fileno(fp)));
res.offset = 0;
res.full_name = filespec;
fclose(fp);
return 1;
return res;
}
return 0; // If they give a full path, fail if not found.
return CFileLocation(); // If they give a full path, fail if not found.
}
// Search the hard drive for files first.
@@ -1057,43 +1088,39 @@ int cf_find_file_location( const char *filespec, int pathtype, int max_out, char
}
if (cfs_slow_search) {
cf_create_default_path_string( longname, sizeof(longname)-1, search_order[ui], filespec, localize );
cf_create_default_path_string(longname, sizeof(longname) - 1, search_order[ui], filespec, localize,
location_flags);
#if defined _WIN32
_finddata_t findstruct;
intptr_t findhandle = _findfirst(longname, &findstruct);
if (findhandle != -1) {
if (size)
*size = findstruct.size;
CFileLocation res;
res.found = true;
res.size = static_cast<size_t>(findstruct.size);
_findclose(findhandle);
if (offset)
*offset = 0;
res.offset = 0;
res.full_name = longname;
if (pack_filename)
strncpy( pack_filename, longname, max_out );
return 1;
return res;
}
#endif
{
FILE *fp = fopen(longname, "rb" );
if (fp) {
if (size)
*size = filelength( fileno(fp) );
CFileLocation res(true);
res.size = static_cast<size_t>(filelength( fileno(fp) ));
fclose(fp);
if (offset)
*offset = 0;
res.offset = 0;
res.full_name = longname;
if (pack_filename)
strncpy(pack_filename, longname, max_out);
return 1;
return res;
}
}
}
@@ -1107,6 +1134,15 @@ int cf_find_file_location( const char *filespec, int pathtype, int max_out, char
if ( (pathtype != CF_TYPE_ANY) && (pathtype != f->pathtype_index) )
continue;
if (location_flags != CF_LOCATION_ALL) {
// If a location flag was specified we need to check if the root of this file satisfies the request
auto root = cf_get_root(f->root_index);
if (!cf_check_location_flags(root->location_flags, location_flags)) {
// Root does not satisfy location flags
continue;
}
}
if (localize) {
// create localized filespec
@@ -1114,70 +1150,58 @@ int cf_find_file_location( const char *filespec, int pathtype, int max_out, char
if ( lcl_add_dir_to_path_with_filename(longname, MAX_PATH_LEN - 1) ) {
if ( !stricmp(longname, f->name_ext) ) {
if (size)
*size = f->size;
CFileLocation res(true);
res.size = static_cast<size_t>(f->size);
res.offset = (size_t)f->pack_offset;
res.data_ptr = f->data;
if (offset)
*offset = (size_t)f->pack_offset;
if (f->data != nullptr) {
// This is an in-memory file so we just copy the pathtype name + file name
res.full_name = Pathtypes[f->pathtype_index].path;
res.full_name += DIR_SEPARATOR_STR;
res.full_name += f->name_ext;
} else if (f->pack_offset < 1) {
// This is a real file, return the actual file path
res.full_name = f->real_name;
} else {
// File is in a pack file
cf_root *r = cf_get_root(f->root_index);
if (data_out)
*data_out = f->data;
if (pack_filename) {
if (f->data != nullptr) {
// This is an in-memory file so we just copy the pathtype name + file name
strncpy(pack_filename, Pathtypes[f->pathtype_index].path, max_out);
strncat(pack_filename, DIR_SEPARATOR_STR, max_out);
strncat(pack_filename, f->name_ext, max_out);
} else if (f->pack_offset < 1) {
// This is a real file, return the actual file path
strncpy( pack_filename, f->real_name, max_out );
} else {
// File is in a pack file
cf_root *r = cf_get_root(f->root_index);
strncpy( pack_filename, r->path, max_out );
}
res.full_name = r->path;
}
return 1;
return res;
}
}
}
// file either not localized or localized version not found
if ( !stricmp(filespec, f->name_ext) ) {
if (size)
*size = f->size;
CFileLocation res(true);
res.size = static_cast<size_t>(f->size);
res.offset = (size_t)f->pack_offset;
res.data_ptr = f->data;
if (offset)
*offset = (size_t)f->pack_offset;
if (f->data != nullptr) {
// This is an in-memory file so we just copy the pathtype name + file name
res.full_name = Pathtypes[f->pathtype_index].path;
res.full_name += DIR_SEPARATOR_STR;
res.full_name += f->name_ext;
} else if (f->pack_offset < 1) {
// This is a real file, return the actual file path
res.full_name = f->real_name;
} else {
// File is in a pack file
cf_root *r = cf_get_root(f->root_index);
if (data_out)
*data_out = f->data;
if (pack_filename) {
if (f->data != nullptr) {
// This is an in-memory file so we just copy the pathtype name + file name
strncpy(pack_filename, Pathtypes[f->pathtype_index].path, max_out);
strncat(pack_filename, DIR_SEPARATOR_STR, max_out);
strncat(pack_filename, f->name_ext, max_out);
} else if (f->pack_offset < 1) {
// This is a real file, return the actual file path
strncpy( pack_filename, f->real_name, max_out );
} else {
// File is in a pack file
cf_root *r = cf_get_root(f->root_index);
strncpy( pack_filename, r->path, max_out );
}
res.full_name = r->path;
}
return 1;
return res;
}
}
return 0;
return CFileLocation();
}
// -- from parselo.cpp --
@@ -1194,14 +1218,11 @@ extern char *stristr(char *str, const char *substr);
* @param ext_list Extension filter list
* @param pathtype See CF_TYPE_ defines in CFILE.H
* @param max_out Maximum string length that should be stuffed into pack_filename
* @param pack_filename OUTPUT: Absolute path and filename of this file. Could be a packfile or the actual file.
* @param size OUTPUT: File size
* @param offset OUTPUT: Offset into pack file. 0 if not a packfile.
* @param localize Undertake localization
*
* @return If not found returns -1, else returns offset into ext_list.
* @return A structure containing information about the found file
*/
int cf_find_file_location_ext( const char *filename, const int ext_num, const char **ext_list, int pathtype, int max_out, char *pack_filename, size_t *size, size_t *offset, bool localize, const void** data_out)
CFileLocationExt cf_find_file_location_ext( const char *filename, const int ext_num, const char **ext_list, int pathtype, bool localize)
{
int cur_ext, i;
uint ui;
@@ -1213,7 +1234,6 @@ int cf_find_file_location_ext( const char *filename, const int ext_num, const ch
Assert( (filename != NULL) && (strlen(filename) < MAX_FILENAME_LEN) );
Assert( (ext_list != NULL) && (ext_num > 1) ); // if we are searching for just one ext
// then this is the wrong function to use
Assert( (pack_filename == NULL) || (max_out > 1) );
// if we have a full path already then fail. this function if for searching via filter only!
@@ -1223,7 +1243,7 @@ int cf_find_file_location_ext( const char *filename, const int ext_num, const ch
if ( strpbrk(filename,"/\\:") ) { // do we have a full path already?
#endif
Int3();
return 0;
return CFileLocationExt();
}
// Search the hard drive for files first.
@@ -1281,44 +1301,35 @@ int cf_find_file_location_ext( const char *filename, const int ext_num, const ch
#if defined _WIN32
_finddata_t findstruct;
intptr_t findhandle = _findfirst(longname, &findstruct);
if (findhandle != -1) {
if (size)
*size = findstruct.size;
if (data_out)
*data_out = nullptr;
CFileLocationExt res(cur_ext);
res.found = true;
res.size = static_cast<size_t>(findstruct.size);
_findclose(findhandle);
if (offset)
*offset = 0;
res.offset = 0;
res.full_name = longname;
if (pack_filename)
strncpy( pack_filename, longname, max_out );
return cur_ext;
return res;
}
#endif
{
FILE *fp = fopen(longname, "rb" );
if (fp) {
if (size)
*size = filelength( fileno(fp) );
if (data_out)
*data_out = nullptr;
CFileLocationExt res(cur_ext);
res.found = true;
res.size = static_cast<size_t>(filelength( fileno(fp) ));
fclose(fp);
if (offset)
*offset = 0;
res.offset = 0;
res.full_name = longname;
if (pack_filename)
strncpy(pack_filename, longname, max_out);
return cur_ext;
return res;
}
}
}
@@ -1359,7 +1370,7 @@ int cf_find_file_location_ext( const char *filename, const int ext_num, const ch
continue;
// ... check that we match the base filename
if ( strnicmp(f->name_ext, filespec, filespec_len) )
if ( strnicmp(f->name_ext, filespec, filespec_len) != 0 )
continue;
// ... make sure that it's one of our supported types
@@ -1403,76 +1414,62 @@ int cf_find_file_location_ext( const char *filename, const int ext_num, const ch
if ( lcl_add_dir_to_path_with_filename(longname, MAX_PATH_LEN - 1) ) {
if ( !stricmp(longname, f->name_ext) ) {
if (size)
*size = f->size;
CFileLocationExt res(cur_ext);
res.found = true;
res.size = static_cast<size_t>(f->size);
res.offset = (size_t)f->pack_offset;
res.data_ptr = f->data;
if (offset)
*offset = f->pack_offset;
if (f->data != nullptr) {
// This is an in-memory file so we just copy the pathtype name + file name
res.full_name = Pathtypes[f->pathtype_index].path;
res.full_name += DIR_SEPARATOR_STR;
res.full_name += f->name_ext;
} else if (f->pack_offset < 1) {
// This is a real file, return the actual file path
res.full_name = f->real_name;
} else {
// File is in a pack file
cf_root *r = cf_get_root(f->root_index);
if (data_out)
*data_out = f->data;
if (pack_filename) {
if (f->data != nullptr) {
// This is an in-memory file so we just copy the pathtype name + file name
strncpy(pack_filename, Pathtypes[f->pathtype_index].path, max_out);
strncat(pack_filename, DIR_SEPARATOR_STR, max_out);
strncat(pack_filename, f->name_ext, max_out);
}
else if (f->pack_offset < 1) {
// This is a real file, return the actual file path
strncpy(pack_filename, f->real_name, max_out);
}
else {
// File is in a pack file
cf_root *r = cf_get_root(f->root_index);
strncpy(pack_filename, r->path, max_out);
}
res.full_name = r->path;
}
// found it, so cleanup and return
file_list_index.clear();
return cur_ext;
return res;
}
}
}
// file either not localized or localized version not found
if ( !stricmp(filespec, f->name_ext) ) {
if (size)
*size = f->size;
CFileLocationExt res(cur_ext);
res.found = true;
res.size = static_cast<size_t>(f->size);
res.offset = (size_t)f->pack_offset;
res.data_ptr = f->data;
if (offset)
*offset = f->pack_offset;
if (f->data != nullptr) {
// This is an in-memory file so we just copy the pathtype name + file name
res.full_name = Pathtypes[f->pathtype_index].path;
res.full_name += DIR_SEPARATOR_STR;
res.full_name += f->name_ext;
} else if (f->pack_offset < 1) {
// This is a real file, return the actual file path
res.full_name = f->real_name;
} else {
// File is in a pack file
cf_root *r = cf_get_root(f->root_index);
if (data_out)
*data_out = f->data;
if (pack_filename) {
if (f->data != nullptr) {
// This is an in-memory file so we just copy the pathtype name + file name
strncpy(pack_filename, Pathtypes[f->pathtype_index].path, max_out);
strncat(pack_filename, DIR_SEPARATOR_STR, max_out);
strncat(pack_filename, f->name_ext, max_out);
}
else if (f->pack_offset < 1) {
// This is a real file, return the actual file path
strncpy(pack_filename, f->real_name, max_out);
}
else {
// File is in a pack file
cf_root *r = cf_get_root(f->root_index);
strncpy(pack_filename, r->path, max_out);
}
res.full_name = r->path;
}
// found it, so cleanup and return
file_list_index.clear();
return cur_ext;
return res;
}
// ok, we're still here, so strip off the extension again in order to
@@ -1483,7 +1480,7 @@ int cf_find_file_location_ext( const char *filename, const int ext_num, const ch
}
}
return -1;
return CFileLocationExt();
}
@@ -1582,7 +1579,11 @@ static int cf_file_already_in_list( SCP_vector<SCP_string> &list, const char *fi
// This one has a 'type', which is a CF_TYPE_* value. Because this specifies the directory
// location, 'filter' only needs to be the filter itself, with no path information.
// See above descriptions of cf_get_file_list() for more information about how it all works.
int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *filter, int sort, SCP_vector<file_list_info> *info )
// Note that filesystem listing is always sorted by name *before* sorting by the
// provided sort order. This isn't strictly needed on NTFS, which always provides the list
// sorted by name. But on mac/linux it's always needed.
int cf_get_file_list(SCP_vector<SCP_string>& list, int pathtype, const char* filter, int sort,
SCP_vector<file_list_info>* info, uint32_t location_flags)
{
char *ptr;
uint i;
@@ -1610,7 +1611,8 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *fi
}
#if defined _WIN32
cf_create_default_path_string( filespec, sizeof(filespec)-1, pathtype, (char*)Get_file_list_child );
cf_create_default_path_string(filespec, sizeof(filespec) - 1, pathtype, (char*)Get_file_list_child, false,
location_flags);
strcat_s(filespec, DIR_SEPARATOR_STR);
strcat_s(filespec, filter);
@@ -1650,7 +1652,8 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *fi
}
#elif defined SCP_UNIX
cf_create_default_path_string( filespec, sizeof(filespec)-1, pathtype, (char*)Get_file_list_child );
cf_create_default_path_string(filespec, sizeof(filespec) - 1, pathtype, (char*)Get_file_list_child, false,
location_flags);
DIR *dirp;
struct dirent *dir;
@@ -1701,6 +1704,10 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *fi
}
#endif
// tcrayford: sort the filesystem listing by name by default to ensure
// a stable order across filesystems
cf_sort_filenames( list, CF_SORT_NAME, info );
bool skip_packfiles = false;
if ( (pathtype == CF_TYPE_PLAYERS) || (pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS) ) {
skip_packfiles = true;
@@ -1718,6 +1725,16 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *fi
continue;
}
if (location_flags != CF_LOCATION_ALL) {
// If a location flag was specified we need to check if the root of this file satisfies the request
auto root = cf_get_root(f->root_index);
if (!cf_check_location_flags(root->location_flags, location_flags)) {
// Root does not satisfy location flags
continue;
}
}
if ( !cf_matches_spec( filter,f->name_ext)) {
continue;
}
@@ -1756,7 +1773,6 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *fi
}
}
if (sort != CF_SORT_NONE) {
cf_sort_filenames( list, sort, info );
}
@@ -1795,7 +1811,8 @@ int cf_file_already_in_list( int num_files, char **list, const char *filename )
// This one has a 'type', which is a CF_TYPE_* value. Because this specifies the directory
// location, 'filter' only needs to be the filter itself, with no path information.
// See above descriptions of cf_get_file_list() for more information about how it all works.
int cf_get_file_list( int max, char **list, int pathtype, const char *filter, int sort, file_list_info *info )
int cf_get_file_list(int max, char** list, int pathtype, const char* filter, int sort, file_list_info* info,
uint32_t location_flags)
{
char *ptr;
uint i;
@@ -1818,7 +1835,7 @@ int cf_get_file_list( int max, char **list, int pathtype, const char *filter, in
char filespec[MAX_PATH_LEN];
#if defined _WIN32
cf_create_default_path_string( filespec, sizeof(filespec)-1, pathtype, filter );
cf_create_default_path_string(filespec, sizeof(filespec) - 1, pathtype, filter, false, location_flags);
_finddata_t find;
intptr_t find_handle;
@@ -1859,7 +1876,7 @@ int cf_get_file_list( int max, char **list, int pathtype, const char *filter, in
}
#elif defined SCP_UNIX
cf_create_default_path_string( filespec, sizeof(filespec)-1, pathtype, NULL );
cf_create_default_path_string(filespec, sizeof(filespec) - 1, pathtype, nullptr, false, location_flags);
DIR *dirp;
struct dirent *dir;
@@ -1932,6 +1949,16 @@ int cf_get_file_list( int max, char **list, int pathtype, const char *filter, in
continue;
}
if (location_flags != CF_LOCATION_ALL) {
// If a location flag was specified we need to check if the root of this file satisfies the request
auto root = cf_get_root(f->root_index);
if (!cf_check_location_flags(root->location_flags, location_flags)) {
// Root does not satisfy location flags
continue;
}
}
if (num_files >= max)
break;
@@ -2015,7 +2042,8 @@ int cf_file_already_in_list_preallocated( int num_files, char arr[][MAX_FILENAME
// This one has a 'type', which is a CF_TYPE_* value. Because this specifies the directory
// location, 'filter' only needs to be the filter itself, with no path information.
// See above descriptions of cf_get_file_list() for more information about how it all works.
int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char **list, int pathtype, const char *filter, int sort, file_list_info *info )
int cf_get_file_list_preallocated(int max, char arr[][MAX_FILENAME_LEN], char** list, int pathtype, const char* filter,
int sort, file_list_info* info, uint32_t location_flags)
{
int num_files = 0, own_flag = 0;
@@ -2044,7 +2072,7 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
// Search the default directories
#if defined _WIN32
cf_create_default_path_string( filespec, sizeof(filespec)-1, pathtype, filter );
cf_create_default_path_string(filespec, sizeof(filespec) - 1, pathtype, filter, false, location_flags);
intptr_t find_handle;
_finddata_t find;
@@ -2085,7 +2113,7 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
}
#elif defined SCP_UNIX
cf_create_default_path_string( filespec, sizeof(filespec)-1, pathtype, NULL );
cf_create_default_path_string(filespec, sizeof(filespec) - 1, pathtype, nullptr, false, location_flags);
DIR *dirp;
struct dirent *dir;
@@ -2121,7 +2149,7 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
if ( !Get_file_list_filter || (*Get_file_list_filter)(dir->d_name) ) {
strncpy(arr[num_files], dir->d_name, MAX_FILENAME_LEN - 1 );
strcpy_s(arr[num_files], dir->d_name );
char *ptr = strrchr(arr[num_files], '.');
if ( ptr ) {
*ptr = 0;
@@ -2156,6 +2184,16 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
continue;
}
if (location_flags != CF_LOCATION_ALL) {
// If a location flag was specified we need to check if the root of this file satisfies the request
auto root = cf_get_root(f->root_index);
if (!cf_check_location_flags(root->location_flags, location_flags)) {
// Root does not satisfy location flags
continue;
}
}
if (num_files >= max)
break;
@@ -2222,7 +2260,8 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
// filename - optional, if set, tacks the filename onto end of path.
// Output: path - Fully qualified pathname.
//Returns 0 if the result would be too long (invalid result)
int cf_create_default_path_string(char *path, uint path_max, int pathtype, const char *filename, bool localize )
int cf_create_default_path_string(char* path, uint path_max, int pathtype, const char* filename, bool localize,
uint32_t location_flags)
{
#ifdef SCP_UNIX
if ( filename && strpbrk(filename,"/") ) {
@@ -2233,7 +2272,22 @@ int cf_create_default_path_string(char *path, uint path_max, int pathtype, const
strncpy( path, filename, path_max );
} else {
cf_root *root = cf_get_root(0);
cf_root* root = nullptr;
for (auto i = 0; i < Num_roots; ++i) {
auto current_root = cf_get_root(i);
if (current_root->roottype != CF_ROOTTYPE_PATH) {
// We want a "real" path here so only path roots are valid
continue;
}
if (cf_check_location_flags(current_root->location_flags, location_flags)) {
// We found a valid root
root = current_root;
break;
}
}
if (!root) {
Assert( filename != NULL );
@@ -2243,12 +2297,7 @@ int cf_create_default_path_string(char *path, uint path_max, int pathtype, const
Assert(CF_TYPE_SPECIFIED(pathtype));
// force a specific directory to search for player files
if ( (pathtype == CF_TYPE_PLAYERS) || (pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS) ) {
strncpy(path, Pilot_file_path.c_str(), path_max);
} else {
strncpy(path, root->path, path_max);
}
strncpy(path, root->path, path_max);
strcat_s(path, path_max, Pathtypes[pathtype].path);
@@ -2294,7 +2343,8 @@ int cf_create_default_path_string(char *path, uint path_max, int pathtype, const
// filename - optional, if set, tacks the filename onto end of path.
// Output: path - Fully qualified pathname.
//Returns 0 if the result would be too long (invalid result)
int cf_create_default_path_string( SCP_string &path, int pathtype, const char *filename, bool localize )
int cf_create_default_path_string(SCP_string& path, int pathtype, const char* filename, bool /*localize*/,
uint32_t location_flags)
{
#ifdef SCP_UNIX
if ( filename && strpbrk(filename,"/") ) {
@@ -2305,7 +2355,22 @@ int cf_create_default_path_string( SCP_string &path, int pathtype, const char *f
path.assign(filename);
} else {
cf_root *root = cf_get_root(0);
cf_root* root = nullptr;
for (auto i = 0; i < Num_roots; ++i) {
auto current_root = cf_get_root(i);
if (current_root->roottype != CF_ROOTTYPE_PATH) {
// We want a "real" path here so only path roots are valid
continue;
}
if (cf_check_location_flags(current_root->location_flags, location_flags)) {
// We found a valid root
root = current_root;
break;
}
}
if (!root) {
Assert( filename != NULL );
@@ -2316,12 +2381,7 @@ int cf_create_default_path_string( SCP_string &path, int pathtype, const char *f
Assert(CF_TYPE_SPECIFIED(pathtype));
std::ostringstream s_path;
// force a specific directory to search for player files
if ( (pathtype == CF_TYPE_PLAYERS) || (pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS) ) {
s_path << Pilot_file_path;
} else {
s_path << root->path;
}
s_path << root->path;
s_path << Pathtypes[pathtype].path;
@@ -2386,3 +2446,26 @@ void cfile_spew_pack_file_crcs()
fclose(out);
}
bool cf_check_location_flags(uint32_t check_flags, uint32_t desired_flags)
{
Assertion((check_flags & CF_LOCATION_ROOT_MASK) != 0, "check_flags must have a valid root value");
Assertion((check_flags & CF_LOCATION_TYPE_MASK) != 0, "check_flags must have a valid type value");
auto check_root = check_flags & CF_LOCATION_ROOT_MASK;
auto desired_root_flags = desired_flags & CF_LOCATION_ROOT_MASK;
// If the root part is not set then assume that every root matches
if (desired_root_flags != 0 && (check_root & desired_root_flags) == 0) {
return false;
}
auto check_type = check_flags & CF_LOCATION_TYPE_MASK;
auto desired_type_flags = desired_flags & CF_LOCATION_TYPE_MASK;
if (desired_type_flags != 0 && (check_type & desired_type_flags) == 0) {
return false;
}
return true;
}
+6 -2
View File
@@ -29,6 +29,8 @@ typedef struct cf_pathtype {
// During cfile_init, verify that Pathtypes[n].index == n for each item
extern cf_pathtype Pathtypes[CF_MAX_PATH_TYPES];
bool cf_check_location_flags(uint32_t check_flags, uint32_t desired_flags);
// Returns the default storage path for files given a
// particular pathtype. In other words, the path to
// the unpacked, non-cd'd, stored on hard drive path.
@@ -39,7 +41,9 @@ extern cf_pathtype Pathtypes[CF_MAX_PATH_TYPES];
// filename - optional, if set, tacks the filename onto end of path.
// Output: path - Fully qualified pathname.
//Returns 0 if result would be too long (invalid result)
int cf_create_default_path_string( char *path, uint path_max, int pathtype, const char *filename=NULL, bool localize = false);
int cf_create_default_path_string( SCP_string &path, int pathtype, const char *filename=NULL, bool localize = false );
int cf_create_default_path_string(char* path, uint path_max, int pathtype, const char* filename = nullptr,
bool localize = false, uint32_t location_flags = CF_LOCATION_ALL);
int cf_create_default_path_string(SCP_string& path, int pathtype, const char* filename = nullptr, bool localize = false,
uint32_t location_flags = CF_LOCATION_ALL);
#endif //_CFILESYSTEM_H
+311 -220
View File
@@ -5,27 +5,27 @@
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
*/
#include "camera/camera.h" //VIEWER_ZOOM_DEFAULT
#include "cmdline/cmdline.h"
#include "camera/camera.h" //VIEWER_ZOOM_DEFAULT
#include "cfile/cfilesystem.h"
#include "fireball/fireballs.h"
#include "globalincs/linklist.h"
#include "globalincs/pstypes.h"
#include "globalincs/systemvars.h"
#include "globalincs/version.h"
#include "graphics/shadows.h"
#include "hud/hudconfig.h"
#include "network/multi.h"
#include "scripting/scripting.h"
#include "parse/sexp.h"
#include "globalincs/version.h"
#include "globalincs/pstypes.h"
#include "osapi/osapi.h"
#include "cfile/cfilesystem.h"
#include "sound/speech.h"
#include "sound/openal.h"
#include "io/joy.h"
#include "network/multi.h"
#include "options/OptionsManager.h"
#include "osapi/osapi.h"
#include "parse/sexp.h"
#include "scripting/scripting.h"
#include "sound/openal.h"
#include "sound/speech.h"
#include "starfield/starfield.h"
#ifdef _WIN32
#include <io.h>
@@ -39,8 +39,8 @@
#include <dirent.h>
#endif
#include <string.h>
#include <stdlib.h>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <jansson.h>
@@ -82,8 +82,8 @@ public:
int name_found; // true if parameter on command line, otherwise false
const int arg_type; // from enum cmdline_arg_type; used for help
cmdline_parm(const char *name, const char *help, const int arg_type, const bool stacks = false);
~cmdline_parm();
cmdline_parm(const char *name, const char *help, const int arg_type, const bool stacks = false) noexcept;
~cmdline_parm() noexcept;
int found();
int get_int();
float get_float();
@@ -100,17 +100,13 @@ extern int Show_framerate; // from freespace.cpp
enum
{
// DO NOT CHANGE ANYTHING ABOUT THESE FIRST TWO OR WILL MESS UP THE LAUNCHER
EASY_DEFAULT = 1 << 1,
EASY_ALL_ON = 1 << 2,
EASY_DEFAULT = 1 << 1, // Default FS2 (All features off)
EASY_ALL_ON = 1 << 2, // All features on
EASY_MEM_ON = 1 << 3,
EASY_MEM_OFF = 1 << 4,
EASY_HI_MEM_ON = 1 << 3, // High memory usage features on
EASY_HI_MEM_OFF = 1 << 4, // High memory usage features off
// Add new flags here
// Combos
EASY_MEM_ALL_ON = EASY_ALL_ON | EASY_MEM_ON,
EASY_DEFAULT_MEM = EASY_DEFAULT | EASY_MEM_OFF
};
enum BuildCaps
@@ -122,6 +118,7 @@ enum BuildCaps
};
#define PARSE_COMMAND_LINE_STRING "-parse_cmdline_only"
#define GET_FLAGS_STRING "-get_flags"
typedef struct
{
@@ -145,114 +142,116 @@ typedef struct
char name[20]; // The actual flag
char desc[40]; // The text that will appear in the launcher (unless its blank, other name is shown)
bool fso_only; // true if this is a fs2_open only feature
int on_flags; // Easy flag which will turn this feature on
int off_flags; // Easy flag which will turn this feature off
int on_flags; // "Easy setting" which will turn this option on
int off_flags; // "Easy setting" which will turn this option off
char type[16]; // Launcher uses this to put flags under different headings
char web_url[256]; // Link to documentation of feature (please use wiki or somewhere constant)
} Flag;
// clang-format off
// Please group them by type, ie graphics, gameplay etc, maximum 20 different types
Flag exe_params[] =
{
{ "-nospec", "Disable specular", true, EASY_DEFAULT_MEM, EASY_MEM_ALL_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-spec", },
{ "-noglow", "Disable glow maps", true, EASY_DEFAULT_MEM, EASY_MEM_ALL_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-glow", },
{ "-noenv", "Disable environment maps", true, EASY_DEFAULT_MEM, EASY_MEM_ALL_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-env", },
{ "-nomotiondebris", "Disable motion debris", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomotiondebris",},
{ "-noscalevid", "Disable scale-to-window for movies", true, 0, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noscalevid", },
{ "-nonormal", "Disable normal maps", true, EASY_DEFAULT_MEM, EASY_MEM_ALL_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-normal" },
{ "-no_emissive_light", "Disable emissive light from ships", true, 0, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_emissive_light" },
{ "-noheight", "Disable height/parallax maps", true, EASY_DEFAULT_MEM, EASY_MEM_ALL_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-height" },
{ "-3dshockwave", "Enable 3D shockwaves", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-3dshockwave" },
{ "-post_process", "Enable post processing", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-post_process" },
{ "-soft_particles", "Enable soft particles", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-soft_particles" },
{ "-fxaa", "Enable FXAA anti-aliasing", true, EASY_MEM_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fxaa" },
{ "-nolightshafts", "Disable lightshafts", true, EASY_DEFAULT, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-flightshaftsoff"},
{ "-fb_explosions", "Enable Framebuffer Shockwaves", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fb_explosions", },
{ "-fb_thrusters", "Enable Framebuffer Thrusters", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fb_thrusters", },
{ "-no_deferred", "Disable Deferred Lighting", true, EASY_DEFAULT_MEM, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_deferred"},
{ "-enable_shadows", "Enable Shadows", true, EASY_MEM_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_shadows"},
{ "-no_vsync", "Disable vertical sync", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_vsync", },
{ "-cache_bitmaps", "Cache bitmaps between missions", true, 0, EASY_DEFAULT_MEM, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-cache_bitmaps", },
{ "-nospec", "Disable specular", 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#-nospec", },
{ "-noglow", "Disable glow 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#-noglow", },
{ "-noenv", "Disable environment 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#-noenv", },
{ "-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" },
{ "-noheight", "Disable height/parallax 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#-noheight" },
{ "-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" },
{ "-no_post_process", "Disable post-processing", 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#-no_post_process" },
{ "-soft_particles", "Enable soft particles", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-soft_particles" },
{ "-aa", "Enable Post-process anti-aliasing", 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#-aa" },
{ "-nolightshafts", "Disable lightshafts", 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#-nolightshafts"},
{ "-fb_explosions", "Enable Framebuffer Shockwaves", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fb_explosions", },
{ "-fb_thrusters", "Enable Framebuffer Thrusters", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fb_thrusters", },
{ "-no_deferred", "Disable Deferred Lighting", 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#-no_deferred"},
{ "-enable_shadows", "Enable Shadows", 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#-enable_shadows"},
{ "-dualscanlines", "Add another pair of scanning lines", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dualscanlines", },
{ "-targetinfo", "Enable info next to target", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-targetinfo", },
{ "-orbradar", "Enable 3D radar", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-orbradar", },
{ "-rearm_timer", "Enable rearm/repair completion timer", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-rearm_timer", },
{ "-ballistic_gauge", "Enable analog ballistic ammo gauge", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ballistic_gauge", },
{ "-no_vsync", "Disable vertical sync", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_vsync", },
{ "-ship_choice_3d", "Use 3D models for ship selection", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ship_choice_3d", },
{ "-weapon_choice_3d", "Use 3D models for weapon selection", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-weapon_choice_3d", },
{ "-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_ap_interrupt", "Disable interrupting autopilot", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_ap_interrupt", },
{ "-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", },
{ "-fps", "Show frames per second on HUD", false, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fps", },
{ "-dualscanlines", "Add another pair of scanning lines", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dualscanlines", },
{ "-targetinfo", "Enable info next to target", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-targetinfo", },
{ "-orbradar", "Enable 3D radar", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-orbradar", },
{ "-rearm_timer", "Enable rearm/repair completion timer", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-rearm_timer", },
{ "-ballistic_gauge", "Enable analog ballistic ammo gauge", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ballistic_gauge", },
{ "-nosound", "Disable all sound", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nosound", },
{ "-nomusic", "Disable music", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomusic", },
{ "-no_enhanced_sound", "Disable enhanced sound", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_enhanced_sound", },
{ "-window", "Run in window", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-window", },
{ "-fullscreen_window", "Run in fullscreen window", false, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fullscreen_window", },
{ "-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", },
{ "-nomotiondebris", "Disable motion debris", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomotiondebris",},
{ "-ship_choice_3d", "Use 3D models for ship selection", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ship_choice_3d", },
{ "-weapon_choice_3d", "Use 3D models for weapon selection", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-weapon_choice_3d", },
{ "-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_ap_interrupt", "Disable interrupting autopilot", true, 0, EASY_DEFAULT, "Gameplay", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_ap_interrupt", },
{ "-portable_mode", "Store config in portable location", false, 0, EASY_DEFAULT, "Launcher", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-portable_mode", },
{ "-nosound", "Disable all sound", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nosound", },
{ "-nomusic", "Disable music", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomusic", },
{ "-no_enhanced_sound", "Disable enhanced sound", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_enhanced_sound", },
{ "-standalone", "Run as standalone server", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-standalone", },
{ "-startgame", "Skip mainhall and start hosting", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-startgame", },
{ "-closed", "Start hosted server as closed", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-closed", },
{ "-restricted", "Host confirms join requests", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-restricted", },
{ "-multilog", "", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-multilog", },
{ "-clientdamage", "", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-clientdamage", },
{ "-mpnoreturn", "Disable flight deck option", true, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-mpnoreturn", },
{ "-portable_mode", "Store config in portable location", false, 0, EASY_DEFAULT, "Launcher", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-portable_mode", },
{ "-no_set_gamma", "Disable setting of gamma", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_set_gamma", },
{ "-nomovies", "Disable video playback", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomovies", },
{ "-noparseerrors", "Disable parsing errors", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noparseerrors", },
{ "-query_speech", "Check if this build has speech", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-query_speech", },
{ "-loadallweps", "Load all weapons, even those not used", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-loadallweps", },
{ "-disable_fbo", "Disable OpenGL RenderTargets", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_fbo", },
{ "-disable_pbo", "Disable OpenGL Pixel Buffer Objects", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_pbo", },
{ "-ati_swap", "Fix colour issues on some ATI cards", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ati_swap", },
{ "-no_3d_sound", "Use only 2D/stereo for sound effects", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_3d_sound", },
{ "-mipmap", "Enable mipmapping", true, 0, EASY_DEFAULT_MEM, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-mipmap", },
{ "-use_gldrawelements","Don't use glDrawRangeElements", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-use_gldrawelements", },
{ "-old_collision", "Use old collision detection system", true, EASY_DEFAULT, EASY_ALL_ON, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-old_collision", },
{ "-gl_finish", "Fix input lag on some ATI+Linux systems", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-gl_finish", },
{ "-no_geo_effects", "Disable geometry shader for effects", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
{ "-set_cpu_affinity", "Sets processor affinity to config value", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
{ "-nograb", "Disables mouse grabbing", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nograb", },
{ "-noshadercache", "Disables the shader cache", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noshadercache", },
{ "-standalone", "Run as standalone server", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-standalone", },
{ "-startgame", "Skip mainhall and start hosting", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-startgame", },
{ "-closed", "Start hosted server as closed", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-closed", },
{ "-restricted", "Host confirms join requests", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-restricted", },
{ "-multilog", "", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-multilog", },
{ "-clientdamage", "", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-clientdamage", },
{ "-mpnoreturn", "Disable flight deck option", true, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-mpnoreturn", },
{ "-gateway_ip", "Set gateway IP address", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-gateway_ip", },
{ "-no_set_gamma", "Disable setting of gamma", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_set_gamma", },
{ "-nomovies", "Disable video playback", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomovies", },
{ "-noparseerrors", "Disable parsing errors", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noparseerrors", },
{ "-loadallweps", "Load all weapons, even those not used", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-loadallweps", },
{ "-disable_fbo", "Disable OpenGL RenderTargets", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_fbo", },
{ "-disable_pbo", "Disable OpenGL Pixel Buffer Objects", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_pbo", },
{ "-ati_swap", "Fix colour issues on some ATI cards", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ati_swap", },
{ "-no_3d_sound", "Use only 2D/stereo for sound effects", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_3d_sound", },
{ "-mipmap", "Enable mipmapping", true, 0, EASY_DEFAULT | EASY_HI_MEM_OFF, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-mipmap", },
{ "-use_gldrawelements","Don't use glDrawRangeElements", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-use_gldrawelements", },
{ "-gl_finish", "Fix input lag on some ATI+Linux systems", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-gl_finish", },
{ "-no_geo_effects", "Disable geometry shader for effects", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_geo_effects", },
{ "-set_cpu_affinity", "Sets processor affinity to config value", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-set_cpu_affinity", },
{ "-nograb", "Disables mouse grabbing", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nograb", },
{ "-noshadercache", "Disables the shader cache", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noshadercache", },
#ifdef WIN32
{ "-fix_registry", "Use a different registry path", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
{ "-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
{ "-ingame_join", "Allow in-game joining", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ingame_join", },
{ "-voicer", "Enable voice recognition", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-voicer", },
{ "-ingame_join", "Allow in-game joining", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ingame_join", },
{ "-voicer", "Enable voice recognition", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-voicer", },
{ "-fps", "Show frames per second on HUD", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fps", },
{ "-bmpmanusage", "Show how many BMPMAN slots are in use", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-bmpmanusage", },
{ "-pos", "Show position of camera", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-pos", },
{ "-window", "Run in window", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-window", },
{ "-fullscreen_window", "Run in fullscreen window", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fullscreen_window", },
{ "-stats", "Show statistics", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-stats", },
{ "-coords", "Show coordinates", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-coords", },
{ "-show_mem_usage", "Show memory usage", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-show_mem_usage", },
{ "-pofspew", "Generate all ibx files immediately", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-pofspew", },
{ "-tablecrcs", "Dump table CRCs for multi validation", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-tablecrcs", },
{ "-missioncrcs", "Dump mission CRCs for multi validation", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-missioncrcs", },
{ "-dis_collisions", "Disable collisions", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dis_collisions", },
{ "-dis_weapons", "Disable weapon rendering", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dis_weapons", },
{ "-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", },
{ "-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", },
{ "-reparse_mainhall", "Reparse mainhall.tbl when loading halls", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-reparse_mainhall", },
{ "-profile_write_file", "Write profiling information to file", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-profile_write_file", },
{ "-no_unfocused_pause","Don't pause if the window isn't focused", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_unfocused_pause", },
{ "-benchmark_mode", "Puts the game into benchmark mode", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-benchmark_mode", },
{ "-noninteractive", "Disables interactive dialogs", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noninteractive", },
{ "-json_pilot", "Dump pilot files in JSON format", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-json_pilot", },
{ "-json_profiling", "Generate JSON profiling output", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-json_profiling", },
{ "-profile_frame_time","Profile engine subsystems", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-profile_frame_timings", },
{ "-debug_window", "Enable the debug window", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-debug_window", },
{ "-bmpmanusage", "Show how many BMPMAN slots are in use", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-bmpmanusage", },
{ "-pos", "Show position of camera", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-pos", },
{ "-stats", "Show statistics", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-stats", },
{ "-coords", "Show coordinates", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-coords", },
{ "-pofspew", "Dump model information to pofspew.txt", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-pofspew", },
{ "-weaponspew", "Dump weapon stats and spreadsheets", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-weaponspew", },
{ "-tablecrcs", "Dump table CRCs for multi validation", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-tablecrcs", },
{ "-missioncrcs", "Dump mission CRCs for multi validation", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-missioncrcs", },
{ "-dis_collisions", "Disable collisions", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dis_collisions", },
{ "-dis_weapons", "Disable weapon rendering", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dis_weapons", },
{ "-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", },
{ "-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", },
{ "-reparse_mainhall", "Reparse mainhall.tbl when loading halls", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-reparse_mainhall", },
{ "-noninteractive", "Disables interactive dialogs", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noninteractive", },
{ "-no_unfocused_pause","Don't pause if the window isn't focused", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_unfocused_pause", },
{ "-benchmark_mode", "Puts the game into benchmark mode", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-benchmark_mode", },
{ "-profile_frame_time","Profile frame time", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-profile_frame_time", },
{ "-profile_write_file", "Write profiling information to file", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-profile_write_file", },
{ "-json_profiling", "Generate JSON profiling output", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-json_profiling", },
{ "-debug_window", "Enable the debug window", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-debug_window", },
{ "-gr_debug", "Output graphics debug information", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-gr_debug", },
};
// clang-format on
// forward declaration
const char * get_param_desc(const char *flag_name);
@@ -276,6 +275,7 @@ cmdline_parm port_arg("-port", "Multiplayer network port", AT_INT);
cmdline_parm multilog_arg("-multilog", NULL, AT_NONE); // Cmdline_multi_log
cmdline_parm client_dodamage("-clientdamage", NULL, AT_NONE); // Cmdline_client_dodamage
cmdline_parm pof_spew("-pofspew", NULL, AT_NONE); // Cmdline_spew_pof_info
cmdline_parm weapon_spew("-weaponspew", nullptr, AT_NONE); // Cmdline_spew_weapon_stats
cmdline_parm mouse_coords("-coords", NULL, AT_NONE); // Cmdline_mouse_coords
cmdline_parm timeout("-timeout", "Multiplayer network timeout (secs)", AT_INT); // Cmdline_timeout
cmdline_parm bit32_arg("-32bit", "Deprecated", AT_NONE); // (only here for retail compatibility reasons, doesn't actually do anything)
@@ -297,6 +297,7 @@ int Cmdline_multi_stream_chat_to_file = 0;
int Cmdline_network_port = -1;
int Cmdline_restricted_game = 0;
int Cmdline_spew_pof_info = 0;
bool Cmdline_spew_weapon_stats = false;
int Cmdline_start_netgame = 0;
int Cmdline_timeout = -1;
int Cmdline_use_last_pilot = 0;
@@ -307,8 +308,6 @@ int Cmdline_use_last_pilot = 0;
// Graphics related
cmdline_parm fov_arg("-fov", "Vertical field-of-view factor", AT_FLOAT); // Cmdline_fov -- comand line FOV -Bobboau
cmdline_parm clip_dist_arg("-clipdist", "Changes the distance from the viewpoint for the near-clipping plane", AT_FLOAT); // Cmdline_clip_dist
cmdline_parm spec_exp_arg("-spec_exp", "Adjusts the size of shiny spots on ships", AT_FLOAT);
cmdline_parm ogl_spec_arg("-ogl_spec", "Shininess of specular light", AT_FLOAT); // Cmdline_ogl_spec
cmdline_parm spec_static_arg("-spec_static", "Adjusts suns contribution to specular highlights", AT_FLOAT);
cmdline_parm spec_point_arg("-spec_point", "Adjusts laser weapons contribution to specular highlights", AT_FLOAT);
cmdline_parm spec_tube_arg("-spec_tube", "Adjusts beam weapons contribution to specular highlights", AT_FLOAT);
@@ -318,15 +317,19 @@ cmdline_parm glow_arg("-noglow", NULL, AT_NONE); // Cmdline_glow -- use B
cmdline_parm nomotiondebris_arg("-nomotiondebris", NULL, AT_NONE); // Cmdline_nomotiondebris -- Removes those ugly floating rocks -C
cmdline_parm noscalevid_arg("-noscalevid", NULL, AT_NONE); // Cmdline_noscalevid -- disable video scaling that fits to window
cmdline_parm spec_arg("-nospec", NULL, AT_NONE); // Cmdline_spec --
cmdline_parm noemissive_arg("-no_emissive_light", "Disable emissive light from ships", AT_NONE); // Cmdline_no_emissive -- don't use emissive light in OGL
cmdline_parm emissive_arg("-emissive_light", "Enable emissive light from ships", AT_NONE); // Cmdline_no_emissive -- don't use emissive light in OGL
cmdline_parm normal_arg("-nonormal", NULL, AT_NONE); // Cmdline_normal -- disable normal mapping
cmdline_parm height_arg("-noheight", NULL, AT_NONE); // Cmdline_height -- enable support for parallax mapping
cmdline_parm enable_3d_shockwave_arg("-3dshockwave", NULL, AT_NONE);
cmdline_parm softparticles_arg("-soft_particles", NULL, AT_NONE);
cmdline_parm postprocess_arg("-post_process", NULL, AT_NONE);
cmdline_parm bloom_intensity_arg("-bloom_intensity", "Set bloom intensity, requires -post_process", AT_INT);
cmdline_parm fxaa_arg("-fxaa", NULL, AT_NONE);
cmdline_parm fxaa_preset_arg("-fxaa_preset", "FXAA quality (0-9), requires -post_process and -fxaa", AT_INT);
cmdline_parm no_postprocess_arg("-no_post_process", "Disables post-processing", AT_NONE);
cmdline_parm bloom_intensity_arg("-bloom_intensity", "Set bloom intensity, requires post-processing", AT_INT);
cmdline_parm post_process_aa_arg("-aa", "Enables post-process antialiasing", AT_NONE);
cmdline_parm post_process_aa_preset_arg("-aa_preset", "Sets the AA effect to use. See the wiki for details", AT_INT);
cmdline_parm deprecated_fxaa_arg("-fxaa", nullptr, AT_NONE);
cmdline_parm deprecated_fxaa_preset_arg("-fxaa_preset", "FXAA quality (0-2), requires post-processing and -fxaa", AT_INT);
cmdline_parm deprecated_smaa_arg("-smaa", nullptr, AT_NONE);
cmdline_parm deprecated_smaa_preset_arg("-smaa_preset", "SMAA quality (0-3), requires post-processing and -smaa", AT_INT);
cmdline_parm fb_explosions_arg("-fb_explosions", NULL, AT_NONE);
cmdline_parm fb_thrusters_arg("-fb_thrusters", NULL, AT_NONE);
cmdline_parm flightshaftsoff_arg("-nolightshafts", NULL, AT_NONE);
@@ -336,38 +339,26 @@ cmdline_parm no_deferred_lighting_arg("-no_deferred", NULL, AT_NONE); // Cmdline
cmdline_parm anisotropy_level_arg("-anisotropic_filter", NULL, AT_INT);
float Cmdline_clip_dist = Default_min_draw_distance;
float Cmdline_fov = 0.75f;
float Cmdline_ogl_spec = 80.0f;
int Cmdline_ambient_factor = 128;
int Cmdline_env = 1;
int Cmdline_mipmap = 0;
int Cmdline_glow = 1;
int Cmdline_nomotiondebris = 0;
int Cmdline_noscalevid = 0;
int Cmdline_spec = 1;
int Cmdline_no_emissive = 0;
int Cmdline_emissive = 0;
int Cmdline_normal = 1;
int Cmdline_height = 1;
int Cmdline_enable_3d_shockwave = 0;
int Cmdline_softparticles = 0;
int Cmdline_postprocess = 0;
int Cmdline_bloom_intensity = 75;
bool Cmdline_fxaa = false;
int Cmdline_fxaa_preset = 6;
extern int Fxaa_preset_last_frame;
bool Cmdline_fb_explosions = 0;
bool Cmdline_fb_thrusters = false;
int Cmdline_bloom_intensity = 25;
extern bool ls_force_off;
int Cmdline_shadow_quality = 0;
int Cmdline_no_deferred_lighting = 0;
int Cmdline_aniso_level = 0;
// Game Speed related
cmdline_parm cache_bitmaps_arg("-cache_bitmaps", NULL, AT_NONE); // Cmdline_cache_bitmaps
cmdline_parm no_fpscap("-no_fps_capping", "Don't limit frames-per-second", AT_NONE); // Cmdline_NoFPSCap
cmdline_parm no_vsync_arg("-no_vsync", NULL, AT_NONE); // Cmdline_no_vsync
int Cmdline_cache_bitmaps = 0; // caching of bitmaps between missions (faster loads, can hit swap on reload with <512 Meg RAM though) - taylor
int Cmdline_NoFPSCap = 0; // Disable FPS capping - kazan
int Cmdline_no_vsync = 0;
@@ -400,10 +391,8 @@ int Cmdline_autopilot_interruptable = 1;
int Cmdline_stretch_menu = 0;
// Audio related
cmdline_parm query_speech_arg("-query_speech", NULL, AT_NONE); // Cmdline_query_speech
cmdline_parm voice_recognition_arg("-voicer", NULL, AT_NONE); // Cmdline_voice_recognition
int Cmdline_query_speech = 0;
int Cmdline_voice_recognition = 0;
int Cmdline_no_enhanced_sound = 0;
@@ -416,16 +405,14 @@ char *Cmdline_mod = NULL; //DTP for mod argument
cmdline_parm almission_arg("-almission", "Autoload multiplayer mission", AT_STRING); // Cmdline_almission -- DTP for autoload Multi mission
cmdline_parm ingamejoin_arg("-ingame_join", NULL, AT_NONE); // Cmdline_ingamejoin
cmdline_parm mpnoreturn_arg("-mpnoreturn", NULL, AT_NONE); // Cmdline_mpnoreturn -- Removes 'Return to Flight Deck' in respawn dialog -C
cmdline_parm missioncrcspew_arg("-missioncrcs", NULL, AT_STRING); // Cmdline_spew_mission_crcs
cmdline_parm tablecrcspew_arg("-tablecrcs", NULL, AT_STRING); // Cmdline_spew_table_crcs
cmdline_parm objupd_arg("-cap_object_update", "Multiplayer object update cap (0-3)", AT_INT);
cmdline_parm gateway_ip_arg("-gateway_ip", "Set gateway IP address", AT_STRING);
char *Cmdline_almission = NULL; //DTP for autoload multi mission.
int Cmdline_ingamejoin = 0;
int Cmdline_mpnoreturn = 0;
char *Cmdline_spew_mission_crcs = NULL;
char *Cmdline_spew_table_crcs = NULL;
int Cmdline_objupd = 3; // client object updates on LAN by default
char *Cmdline_gateway_ip = nullptr;
// Launcher related options
cmdline_parm portable_mode("-portable_mode", NULL, AT_NONE);
@@ -443,7 +430,6 @@ cmdline_parm atiswap_arg("-ati_swap", NULL, AT_NONE); // Cmdline_atiswap
cmdline_parm no3dsound_arg("-no_3d_sound", NULL, AT_NONE); // Cmdline_no_3d_sound - Disable use of full 3D sounds
cmdline_parm no_drawrangeelements("-use_gldrawelements", NULL, AT_NONE); // Cmdline_drawelements -- Uses glDrawElements instead of glDrawRangeElements
cmdline_parm keyboard_layout("-keyboard_layout", "Specify keyboard layout (qwertz or azerty)", AT_STRING);
cmdline_parm old_collision_system("-old_collision", NULL, AT_NONE); // Cmdline_old_collision_sys
cmdline_parm gl_finish ("-gl_finish", NULL, AT_NONE);
cmdline_parm no_geo_sdr_effects("-no_geo_effects", NULL, AT_NONE);
cmdline_parm set_cpu_affinity("-set_cpu_affinity", NULL, AT_NONE);
@@ -493,15 +479,15 @@ cmdline_parm frame_profile_write_file("-profile_write_file", NULL, AT_NONE); //
cmdline_parm no_unfocused_pause_arg("-no_unfocused_pause", NULL, AT_NONE); //Cmdline_no_unfocus_pause
cmdline_parm benchmark_mode_arg("-benchmark_mode", NULL, AT_NONE); //Cmdline_benchmark_mode
cmdline_parm noninteractive_arg("-noninteractive", NULL, AT_NONE); //Cmdline_noninteractive
cmdline_parm json_pilot("-json_pilot", NULL, AT_NONE); //Cmdline_json_pilot
cmdline_parm json_profiling("-json_profiling", NULL, AT_NONE); //Cmdline_json_profiling
cmdline_parm show_video_info("-show_video_info", NULL, AT_NONE); //Cmdline_show_video_info
cmdline_parm frame_profile_arg("-profile_frame_time", NULL, AT_NONE); //Cmdline_frame_profile
cmdline_parm debug_window_arg("-debug_window", NULL, AT_NONE); // Cmdline_debug_window
cmdline_parm graphics_debug_output_arg("-gr_debug", nullptr, AT_NONE); // Cmdline_graphics_debug_output
cmdline_parm log_to_stdout_arg("-stdout_log", nullptr, AT_NONE); // Cmdline_log_to_stdout
char *Cmdline_start_mission = NULL;
int Cmdline_old_collision_sys = 0;
int Cmdline_dis_collisions = 0;
int Cmdline_dis_weapons = 0;
bool Cmdline_output_sexp_info = false;
@@ -524,16 +510,18 @@ bool Cmdline_profile_write_file = false;
bool Cmdline_no_unfocus_pause = false;
bool Cmdline_benchmark_mode = false;
bool Cmdline_noninteractive = false;
bool Cmdline_json_pilot = false;
bool Cmdline_json_profiling = false;
bool Cmdline_frame_profile = false;
bool Cmdline_show_video_info = false;
bool Cmdline_debug_window = false;
bool Cmdline_graphics_debug_output = false;
bool Cmdline_log_to_stdout = false;
// Other
cmdline_parm get_flags_arg("-get_flags", "Output the launcher flags file", AT_STRING);
cmdline_parm get_flags_arg(GET_FLAGS_STRING, "Output the launcher flags file", AT_STRING);
cmdline_parm output_sexp_arg("-output_sexps", NULL, AT_NONE); //WMC - outputs all SEXPs to sexps.html
cmdline_parm output_scripting_arg("-output_scripting", NULL, AT_NONE); //WMC
cmdline_parm output_script_json_arg("-output_script_json", nullptr, AT_NONE); // m!m
// Deprecated flags - CommanderDJ
cmdline_parm deprecated_spec_arg("-spec", "Deprecated", AT_NONE);
@@ -546,6 +534,9 @@ cmdline_parm deprecated_htl_arg("-nohtl", "Deprecated", AT_NONE);
cmdline_parm deprecated_brieflighting_arg("-brief_lighting", "Deprecated", AT_NONE);
cmdline_parm deprecated_sndpreload_arg("-snd_preload", "Deprecated", AT_NONE);
cmdline_parm deprecated_missile_lighting_arg("-missile_lighting", "Deprecated", AT_NONE);
cmdline_parm deprecated_cache_bitmaps_arg("-cache_bitmaps", "Deprecated", AT_NONE);
cmdline_parm deprecated_no_emissive_arg("-no_emissive_light", "Deprecated", AT_NONE);
cmdline_parm deprecated_postprocess_arg("-post_process", "Deprecated", AT_NONE);
int Cmdline_deprecated_spec = 0;
int Cmdline_deprecated_glow = 0;
@@ -556,6 +547,8 @@ int Cmdline_deprecated_jpgtga = 0;
int Cmdline_deprecated_nohtl = 0;
bool Cmdline_deprecated_brief_lighting = 0;
bool Cmdline_deprecated_missile_lighting = false;
bool Cmdline_deprecated_cache_bitmaps = false;
bool Cmdline_deprecated_postprocess = false;
#ifndef NDEBUG
// NOTE: this assumes that os_init() has already been called but isn't a fatal error if it hasn't
@@ -626,6 +619,14 @@ void cmdline_debug_print_cmdline()
{
mprintf(("Deprecated flag '-missile_lighting' found. Please remove from your cmdline.\n"));
}
if (Cmdline_deprecated_cache_bitmaps) {
mprintf(("Deprecated flag '-cache_bitmaps' found. Please remove from your cmdline.\n"));
}
if (Cmdline_deprecated_postprocess) {
mprintf(("Deprecated flag '-post_process' found. Please remove from your cmdline.\n"));
}
}
#endif
@@ -818,7 +819,7 @@ void os_validate_parms(int argc, char *argv[])
size_t sp = 0;
for (parmp = GET_FIRST(&Parm_list); parmp !=END_OF_LIST(&Parm_list); parmp = GET_NEXT(parmp) ) {
// don't output deprecated flags
if (stricmp("deprecated", parmp->help)) {
if (stricmp("deprecated", parmp->help) != 0) {
sp = strlen(parmp->name);
if (parmp->arg_type != AT_NONE) {
atp = strlen(cmdline_arg_types[parmp->arg_type]);
@@ -930,11 +931,11 @@ void os_process_cmdline(char* cmdline)
delete[] argv;
}
bool has_cmdline_only_flag(int argc, char *argv[])
bool has_cmdline_only_or_get_flags(int argc, char *argv[])
{
for (int i = 0; i < argc; ++i)
{
if (!strcmp(argv[i], PARSE_COMMAND_LINE_STRING))
if (!strcmp(argv[i], PARSE_COMMAND_LINE_STRING) || !strcmp(argv[i], GET_FLAGS_STRING))
{
return true;
}
@@ -966,7 +967,9 @@ void os_init_cmdline(int argc, char *argv[])
FILE *fp;
if (!has_cmdline_only_flag(argc, argv)) {
// Don't parse any command-line config files if we specified PARSE_COMMAND_LINE_STRING (to explicitly prevent it),
// or GET_FLAGS_STRING (because the engine is going to do a quick exit and for GitHub issue #1221)
if (!has_cmdline_only_or_get_flags(argc, argv)) {
// Only parse the config file in the current directory if we are in legacy config mode
if (os_is_legacy_mode()) {
// read the cmdline_fso.cfg file from the data folder, and pass the command line arguments to
@@ -1031,7 +1034,7 @@ void os_init_cmdline(int argc, char *argv[])
fclose(fp);
}
}
} // If cmdline included PARSE_COMMAND_LINE_STRING
} // If cmdline included PARSE_COMMAND_LINE_STRING or GET_FLAGS_STRING
// By parsing cmdline last, anything actually on the command line will take precedence.
os_parse_parms(argc, argv);
@@ -1047,7 +1050,7 @@ void os_init_cmdline(int argc, char *argv[])
* @param arg_type_ parameters arguement type (if any)
* @param stacks_ can the parameter be stacked
*/
cmdline_parm::cmdline_parm(const char *name_, const char *help_, const int arg_type_, const bool stacks_):
cmdline_parm::cmdline_parm(const char *name_, const char *help_, const int arg_type_, const bool stacks_) noexcept:
name(name_), help(help_), stacks(stacks_), arg_type(arg_type_)
{
args = NULL;
@@ -1070,7 +1073,7 @@ cmdline_parm::cmdline_parm(const char *name_, const char *help_, const int arg_t
// destructor - frees any allocated memory
cmdline_parm::~cmdline_parm()
cmdline_parm::~cmdline_parm() noexcept
{
#ifndef FRED
if (args) {
@@ -1476,7 +1479,7 @@ static void write_flags_file() {
}
static flag_output_type get_flags_output_type() {
Assertion(get_flags_arg.found(), "This function is only valid if -get_flags is present!");
Assertion(get_flags_arg.found(), "This function is only valid if " GET_FLAGS_STRING " is present!");
if (!get_flags_arg.has_param()) {
// Default to binary mode
@@ -1551,24 +1554,6 @@ bool SetCmdlineParams()
Cmdline_extra_warn = 1;
}
if ( missioncrcspew_arg.found() ) {
Cmdline_spew_mission_crcs = missioncrcspew_arg.str();
// strip off blank space at end if it's there
if ( Cmdline_spew_mission_crcs[strlen(Cmdline_spew_mission_crcs)-1] == ' ' ) {
Cmdline_spew_mission_crcs[strlen(Cmdline_spew_mission_crcs)-1] = '\0';
}
}
if ( tablecrcspew_arg.found() ) {
Cmdline_spew_table_crcs = tablecrcspew_arg.str();
// strip off blank space at end if it's there
if ( Cmdline_spew_table_crcs[strlen(Cmdline_spew_table_crcs)-1] == ' ' ) {
Cmdline_spew_table_crcs[strlen(Cmdline_spew_table_crcs)-1] = '\0';
}
}
if (!Fred_running) { //There is no standalone FRED
// is this a standalone server??
if (standalone_arg.found()) {
@@ -1659,6 +1644,11 @@ bool SetCmdlineParams()
Cmdline_network_port = port_arg.get_int();
}
// get IP address of gateway, for auto port forwarding
if ( gateway_ip_arg.found() ) {
Cmdline_gateway_ip = gateway_ip_arg.str();
}
// the connect argument specifies to join a game at this particular address
if ( connect_arg.found() ) {
Cmdline_use_last_pilot = 1;
@@ -1681,6 +1671,11 @@ bool SetCmdlineParams()
Cmdline_spew_pof_info = 1;
}
// spew weapon stats
if (weapon_spew.found()) {
Cmdline_spew_weapon_stats = true;
}
// mouse coords
if(mouse_coords.found()){
Cmdline_mouse_coords = 1;
@@ -1692,18 +1687,32 @@ bool SetCmdlineParams()
}
// d3d windowed
if(window_arg.found()){
if(window_arg.found()) {
// We need to set both values since we don't know if we are going to use the new config system
options::OptionsManager::instance()->setOverride("Graphics.WindowMode", "0");
Cmdline_window = 1;
}
if ( fullscreen_window_arg.found( ) )
{
options::OptionsManager::instance()->setOverride("Graphics.WindowMode", "1");
Cmdline_fullscreen_window = 1;
Cmdline_window = 0; /* Make sure no-one sets both */
}
if(res_arg.found()){
Cmdline_res = res_arg.str();
int width = 0;
int height = 0;
if ( sscanf(Cmdline_res, "%dx%d", &width, &height) == 2 ) {
SCP_string override;
sprintf(override, "{\"width\":%d,\"height\":%d}", width, height);
options::OptionsManager::instance()->setOverride("Graphics.Resolution", override);
} else {
mprintf(("Failed to parse -res parameter \"%s\". Must be in format \"<width>x<height>\".", Cmdline_res));
}
}
if(center_res_arg.found()){
Cmdline_center_res = center_res_arg.str();
@@ -1783,7 +1792,7 @@ bool SetCmdlineParams()
}
if ( nomotiondebris_arg.found() ) {
Cmdline_nomotiondebris = 1;
Motion_debris_enabled = false;
}
if( mipmap_arg.found() ) {
@@ -1795,11 +1804,11 @@ bool SetCmdlineParams()
}
if ( fov_arg.found() ) {
Cmdline_fov = fov_arg.get_float();
if (Cmdline_fov > 0.1) {
VIEWER_ZOOM_DEFAULT = Cmdline_fov;
auto val = fov_arg.get_float();
if (val > 0.1) {
VIEWER_ZOOM_DEFAULT = val;
} else {
VIEWER_ZOOM_DEFAULT = Cmdline_fov = 0.75f;
VIEWER_ZOOM_DEFAULT = 0.75f;
}
}
@@ -1813,7 +1822,7 @@ bool SetCmdlineParams()
}
if ( use_3dwarp.found() ) {
Cmdline_3dwarp = 1;
Fireball_use_3d_warp = true;
}
if ( use_warp_flash.found() ) {
@@ -1827,11 +1836,8 @@ bool SetCmdlineParams()
if ( stretch_menu.found() ) {
Cmdline_stretch_menu = 1;
}
// specular comand lines
if ( spec_exp_arg.found() ) {
specular_exponent_value = spec_exp_arg.get_float();
}
// specular comand lines
if ( spec_point_arg.found() ) {
static_point_factor = spec_point_arg.get_float();
}
@@ -1856,7 +1862,7 @@ bool SetCmdlineParams()
if(no_vsync_arg.found() )
{
Cmdline_no_vsync = 1;
Gr_enable_vsync = false;
}
if ( normal_arg.found() ) {
@@ -1866,23 +1872,44 @@ bool SetCmdlineParams()
if ( height_arg.found() ) {
Cmdline_height = 0;
}
if (fxaa_arg.found() ) {
Cmdline_fxaa = true;
if (fxaa_preset_arg.found()) {
Cmdline_fxaa_preset = fxaa_preset_arg.get_int();
if (post_process_aa_arg.found() || post_process_aa_preset_arg.found()) {
Gr_aa_mode = AntiAliasMode::SMAA_Low;
if (post_process_aa_preset_arg.found()) {
switch (post_process_aa_preset_arg.get_int()) {
case 0:
Gr_aa_mode = AntiAliasMode::FXAA_Low;
break;
case 1:
Gr_aa_mode = AntiAliasMode::FXAA_Medium;
break;
case 2:
Gr_aa_mode = AntiAliasMode::FXAA_High;
break;
case 3:
Gr_aa_mode = AntiAliasMode::SMAA_Low;
break;
case 4:
Gr_aa_mode = AntiAliasMode::SMAA_Medium;
break;
case 5:
Gr_aa_mode = AntiAliasMode::SMAA_High;
break;
case 6:
Gr_aa_mode = AntiAliasMode::SMAA_Ultra;
break;
}
}
Fxaa_preset_last_frame = Cmdline_fxaa_preset;
}
// If any of the AA presets were chosen, update the _last_frame AA mode to avoid an unnecessary
// shader recompile.
Gr_aa_mode_last_frame = Gr_aa_mode;
if ( glow_arg.found() )
Cmdline_glow = 0;
if ( query_speech_arg.found() )
Cmdline_query_speech = 1;
if ( ship_choice_3d_arg.found() )
Cmdline_ship_choice_3d = 1;
@@ -1902,6 +1929,9 @@ bool SetCmdlineParams()
if ( output_scripting_arg.found() )
Output_scripting_meta = true;
if (output_script_json_arg.found() )
Output_scripting_json = true;
if (output_sexp_arg.found() ) {
Cmdline_output_sexp_info = true;
}
@@ -1965,13 +1995,6 @@ bool SetCmdlineParams()
Cmdline_ballistic_gauge = 1;
}
if ( cache_bitmaps_arg.found() ) {
Cmdline_cache_bitmaps = 1;
}
if(old_collision_system.found())
Cmdline_old_collision_sys = 1;
if(dis_collisions.found())
Cmdline_dis_collisions = 1;
@@ -1982,14 +2005,8 @@ bool SetCmdlineParams()
Cmdline_no_fbo = 1;
}
if ( noemissive_arg.found() ) {
Cmdline_no_emissive = 1;
}
if ( ogl_spec_arg.found() ) {
Cmdline_ogl_spec = ogl_spec_arg.get_float();
CLAMP(Cmdline_ogl_spec, 0.0f, 128.0f);
if ( emissive_arg.found() ) {
Cmdline_emissive = 1;
}
if ( rearm_timer_arg.found() )
@@ -2021,17 +2038,17 @@ bool SetCmdlineParams()
if ( fb_explosions_arg.found() )
{
Cmdline_fb_explosions = 1;
Gr_framebuffer_effects.set(FramebufferEffects::Shockwaves, true);
}
if (fb_thrusters_arg.found())
{
Cmdline_fb_thrusters = true;
Gr_framebuffer_effects.set(FramebufferEffects::Thrusters, true);
}
if ( postprocess_arg.found() )
if ( no_postprocess_arg.found() )
{
Cmdline_postprocess = 1;
Gr_post_processing_enabled = false;
}
if ( bloom_intensity_arg.found() )
@@ -2051,12 +2068,32 @@ bool SetCmdlineParams()
if( enable_shadows_arg.found() )
{
Cmdline_shadow_quality = 2;
Shadow_quality = ShadowQuality::Medium;
}
if( shadow_quality_arg.found() )
{
Cmdline_shadow_quality = shadow_quality_arg.get_int();
switch (shadow_quality_arg.get_int()) {
case 0:
Shadow_quality = ShadowQuality::Disabled;
break;
case 1:
Shadow_quality = ShadowQuality::Low;
break;
case 2:
Shadow_quality = ShadowQuality::Medium;
break;
case 3:
Shadow_quality = ShadowQuality::High;
break;
case 4:
Shadow_quality = ShadowQuality::Ultra;
break;
default:
mprintf(("Invalid shadow quality %d. Disabling shadows...\n", shadow_quality_arg.get_int()));
Shadow_quality = ShadowQuality::Disabled;
break;
}
}
if( no_deferred_lighting_arg.found() )
@@ -2089,11 +2126,6 @@ bool SetCmdlineParams()
Cmdline_noninteractive = true;
}
if (json_pilot.found())
{
Cmdline_json_pilot = true;
}
if (json_profiling.found())
{
Cmdline_json_profiling = true;
@@ -2108,6 +2140,14 @@ bool SetCmdlineParams()
Cmdline_debug_window = true;
}
if (graphics_debug_output_arg.found()) {
Cmdline_graphics_debug_output = true;
}
if (log_to_stdout_arg.found()) {
Cmdline_log_to_stdout = true;
}
if (show_video_info.found())
{
Cmdline_show_video_info = true;
@@ -2159,6 +2199,57 @@ bool SetCmdlineParams()
Cmdline_deprecated_missile_lighting = true;
}
if (deprecated_cache_bitmaps_arg.found()) {
Cmdline_deprecated_cache_bitmaps = true;
}
if (deprecated_no_emissive_arg.found()) {
Cmdline_emissive = 0;
}
if (deprecated_postprocess_arg.found()) {
Cmdline_deprecated_postprocess = true;
}
if (deprecated_fxaa_arg.found() ) {
Gr_aa_mode = AntiAliasMode::FXAA_Medium;
if (deprecated_fxaa_preset_arg.found()) {
auto val = deprecated_fxaa_preset_arg.get_int();
if (val > 6) {
Gr_aa_mode = AntiAliasMode::FXAA_High;
} else if (val > 3) {
Gr_aa_mode = AntiAliasMode::FXAA_Medium;
} else {
Gr_aa_mode = AntiAliasMode::FXAA_Low;
}
}
}
if (deprecated_smaa_arg.found()) {
Gr_aa_mode = AntiAliasMode::SMAA_Medium;
if (deprecated_smaa_preset_arg.found()) {
switch (deprecated_smaa_preset_arg.get_int()) {
case 0:
Gr_aa_mode = AntiAliasMode::SMAA_Low;
break;
case 1:
Gr_aa_mode = AntiAliasMode::SMAA_Medium;
break;
case 2:
Gr_aa_mode = AntiAliasMode::SMAA_High;
break;
case 3:
Gr_aa_mode = AntiAliasMode::SMAA_Ultra;
break;
default:
Gr_aa_mode = AntiAliasMode::SMAA_Ultra;
break;
}
}
}
return true;
}
+6 -17
View File
@@ -53,36 +53,25 @@ extern char *Cmdline_center_res;
// FSO OPTIONS -------------------------------------------------
// Graphics related
extern double specular_exponent_value;
extern float Cmdline_clip_dist;
extern float Cmdline_fov;
extern float Cmdline_ogl_spec;
extern float static_light_factor;
extern float static_point_factor;
extern float static_tube_factor;
extern int Cmdline_ambient_factor;
extern int Cmdline_env;
extern int Cmdline_glow;
extern int Cmdline_nomotiondebris;
extern int Cmdline_noscalevid; // disables fit-to-window for movies - taylor
extern int Cmdline_spec;
extern int Cmdline_normal;
extern int Cmdline_height;
extern int Cmdline_enable_3d_shockwave;
extern int Cmdline_softparticles;
extern int Cmdline_postprocess;
extern int Cmdline_bloom_intensity;
extern bool Cmdline_fxaa;
extern int Cmdline_fxaa_preset;
extern bool Cmdline_fb_explosions;
extern bool Cmdline_fb_thrusters;
extern int Cmdline_shadow_quality;
extern int Cmdline_no_deferred_lighting;
extern int Cmdline_no_emissive;
extern int Cmdline_emissive;
extern int Cmdline_aniso_level;
// Game Speed related
extern int Cmdline_cache_bitmaps;
extern int Cmdline_NoFPSCap;
extern int Cmdline_no_vsync;
@@ -102,7 +91,6 @@ extern int Cmdline_autopilot_interruptable;
extern int Cmdline_stretch_menu;
// Audio related
extern int Cmdline_query_speech;
extern int Cmdline_voice_recognition;
extern int Cmdline_no_enhanced_sound;
@@ -112,9 +100,8 @@ extern char *Cmdline_mod; // DTP for mod support
extern char *Cmdline_almission; // DTP for autoload mission (for multi only)
extern int Cmdline_ingamejoin;
extern int Cmdline_mpnoreturn;
extern char *Cmdline_spew_mission_crcs;
extern char *Cmdline_spew_table_crcs;
extern int Cmdline_objupd;
extern char *Cmdline_gateway_ip;
// Launcher related options
extern bool Cmdline_portable_mode;
@@ -141,7 +128,6 @@ extern bool Cmdline_alternate_registry_path;
// Developer/Testing related
extern char *Cmdline_start_mission;
extern int Cmdline_old_collision_sys;
extern int Cmdline_dis_collisions;
extern int Cmdline_dis_weapons;
extern bool Cmdline_output_sexp_info;
@@ -157,10 +143,13 @@ extern bool Cmdline_profile_write_file;
extern bool Cmdline_no_unfocus_pause;
extern bool Cmdline_benchmark_mode;
extern bool Cmdline_noninteractive;
extern bool Cmdline_json_pilot;
extern bool Cmdline_json_profiling;
extern bool Cmdline_frame_profile;
extern bool Cmdline_show_video_info;
extern bool Cmdline_debug_window;
extern bool Cmdline_graphics_debug_output;
extern bool Cmdline_log_to_stdout;
extern bool Cmdline_spew_weapon_stats;
#endif
+1 -21
View File
@@ -53,26 +53,6 @@ void cmeasure_set_ship_launch_vel(object *objp, object *parent_objp, int arand)
vm_vec_copy_scale(&objp->phys_info.desired_vel, &objp->orient.vec.fvec, objp->phys_info.max_vel.xyz.z );
}
void cmeasure_select_next(ship *shipp)
{
Assert(shipp != NULL);
int i, new_index;
for (i = 1; i < Num_weapon_types; i++)
{
new_index = (shipp->current_cmeasure + i) % Num_weapon_types;
if(Weapon_info[new_index].wi_flags[Weapon::Info_Flags::Cmeasure])
{
shipp->current_cmeasure = new_index;
return;
}
}
mprintf(("Countermeasure type set to %i in frame %i\n", shipp->current_cmeasure, Framecount));
}
/**
* @brief If this is a player countermeasure, let the player know they evaded a missile.
* @param objp [description]
@@ -92,7 +72,7 @@ void cmeasure_maybe_alert_success(object *objp)
if ( objp->parent == OBJ_INDEX(Player_obj) ) {
hud_start_text_flash(XSTR("Evaded", 1430), 800);
snd_play(gamesnd_get_game_sound(ship_get_sound(Player_obj, SND_MISSILE_EVADED_POPUP)));
snd_play(gamesnd_get_game_sound(ship_get_sound(Player_obj, GameSounds::MISSILE_EVADED_POPUP)));
} else if ( Objects[objp->parent].flags[Object::Object_Flags::Player_ship] ) {
send_countermeasure_success_packet( objp->parent );
}
-1
View File
@@ -28,7 +28,6 @@ extern int Cmeasures_homing_check;
extern int Countermeasures_enabled;
extern void cmeasure_set_ship_launch_vel(object *objp, object *parent_objp, int arand);
extern void cmeasure_select_next(object *objp);
extern void cmeasure_maybe_alert_success(object *objp);
#endif // _CMEASURE_H
+58 -76
View File
@@ -38,7 +38,6 @@
#define NUM_SYSTEM_KEYS 14
#define NUM_BUTTONS 19
#define NUM_TABS 4
@@ -157,11 +156,6 @@ char *Mouse_button_text[NUM_MOUSE_TEXT];
char *Mouse_axis_text[NUM_MOUSE_AXIS_TEXT];
char *Invert_text[NUM_INVERT_TEXT];
ubyte System_keys[NUM_SYSTEM_KEYS] = {
KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10,
KEY_F11, KEY_F12, KEY_PRINT_SCRN
};
int Control_check_count = 0;
static int Tab; // which tab we are currently in
@@ -356,7 +350,7 @@ DCF_BOOL(show_controls_info, Show_controls_info);
static int Axes_origin[JOY_NUM_AXES];
static int joy_get_unscaled_reading(int raw, int axn)
static int joy_get_unscaled_reading(int raw)
{
int rng;
@@ -522,7 +516,9 @@ void control_config_list_prepare()
Num_cc_lines = y = z = 0;
while (z < CCFG_MAX) {
if (Control_config[z].tab == Tab && !Control_config[z].disabled) {
if (Control_config[z].hasXSTR) {
if (Control_config[z].indexXSTR > 1) {
Cc_lines[Num_cc_lines].label = XSTR(Control_config[z].text, Control_config[z].indexXSTR);
} else if (Control_config[z].indexXSTR == 1) {
Cc_lines[Num_cc_lines].label = XSTR(Control_config[z].text, CONTROL_CONFIG_XSTR + z);
} else {
Cc_lines[Num_cc_lines].label = Control_config[z].text;
@@ -615,7 +611,7 @@ int control_config_undo_last()
int i, z, tab;
if (!Config_item_undo) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -664,7 +660,7 @@ int control_config_undo_last()
free_undo_block();
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
return 0;
}
@@ -715,7 +711,7 @@ int control_config_remove_binding()
config_item_undo *ptr;
if (Selected_line < 0) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -723,7 +719,7 @@ int control_config_remove_binding()
if (z & JOY_AXIS) {
z &= ~JOY_AXIS;
if (Axis_map_to[z] < 0) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -731,13 +727,13 @@ int control_config_remove_binding()
Axis_map_to[z] = -1;
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
Selected_item = -1;
return 0;
}
if ((Control_config[z].joy_id < 0) && (Control_config[z].key_id < 0)) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -755,7 +751,7 @@ int control_config_remove_binding()
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
Selected_item = -1;
return 0;
}
@@ -766,7 +762,7 @@ int control_config_clear_other()
config_item_undo *ptr;
if (Selected_line < 0) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -776,7 +772,7 @@ int control_config_clear_other()
z &= ~JOY_AXIS;
if (Axis_map_to[z] < 0) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -787,7 +783,7 @@ int control_config_clear_other()
}
if (!total) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -808,7 +804,7 @@ int control_config_clear_other()
}
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
return 0;
}
@@ -820,12 +816,12 @@ int control_config_clear_other()
}
}
if (!total) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
if ((Control_config[z].joy_id < 0) && (Control_config[z].key_id < 0)) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -850,7 +846,7 @@ int control_config_clear_other()
}
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
return 0;
}
@@ -867,7 +863,7 @@ int control_config_clear_all()
}
if (!total) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -888,7 +884,7 @@ int control_config_clear_all()
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(SND_RESET_PRESSED);
gamesnd_play_iface(InterfaceSounds::RESET_PRESSED);
return 0;
}
@@ -945,7 +941,7 @@ int control_config_do_reset()
}
if (!total && !cycling_presets) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -981,7 +977,7 @@ int control_config_do_reset()
control_config_conflict_check();
control_config_list_prepare();
gamesnd_play_iface(SND_RESET_PRESSED);
gamesnd_play_iface(InterfaceSounds::RESET_PRESSED);
return 0;
}
@@ -1005,7 +1001,7 @@ void control_config_reset_defaults(int presetnum)
Control_config[i].key_id = preset[i].key_default;
Control_config[i].joy_id = preset[i].joy_default;
Control_config[i].tab = preset[i].tab;
Control_config[i].hasXSTR = preset[i].hasXSTR;
Control_config[i].indexXSTR = preset[i].indexXSTR;
Control_config[i].type = preset[i].type;
Control_config[i].disabled = preset[i].disabled;
}
@@ -1026,10 +1022,10 @@ void control_config_scroll_screen_up()
}
Selected_item = -1;
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
} else {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
}
}
@@ -1042,10 +1038,10 @@ void control_config_scroll_line_up()
}
Selected_item = -1;
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
} else {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
}
}
@@ -1059,10 +1055,10 @@ void control_config_scroll_screen_down()
}
Selected_item = -1;
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
} else {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
}
}
@@ -1076,10 +1072,10 @@ void control_config_scroll_line_down()
}
Selected_item = -1;
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
} else {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
}
}
@@ -1091,13 +1087,13 @@ void control_config_toggle_modifier(int bit)
Assert(!(z & JOY_AXIS));
k = Control_config[z].key_id;
if (k < 0) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return;
}
control_config_bind_key(z, k ^ bit);
control_config_conflict_check();
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
}
void control_config_toggle_invert()
@@ -1118,7 +1114,7 @@ void control_config_do_bind()
game_flush();
// if ((Selected_line < 0) || (Cc_lines[Selected_line].cc_index & JOY_AXIS)) {
if (Selected_line < 0) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return;
}
@@ -1142,7 +1138,7 @@ void control_config_do_bind()
Search_mode = 0;
Last_key = -1;
Axis_override = -1;
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
}
void control_config_do_search()
@@ -1166,7 +1162,7 @@ void control_config_do_search()
Binding_mode = 0;
Search_mode = 1;
Last_key = -1;
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
}
void control_config_do_cancel(int fail = 0)
@@ -1189,9 +1185,9 @@ void control_config_do_cancel(int fail = 0)
Binding_mode = Search_mode = 0;
if (fail){
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
} else {
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
}
}
@@ -1206,13 +1202,13 @@ int control_config_accept()
}
if (i < NUM_TABS) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
hud_squadmsg_save_keys(); // rebuild map for saving/restoring keys in squadmsg mode
gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
gamesnd_play_iface(SND_COMMIT_PRESSED);
gamesnd_play_iface(InterfaceSounds::COMMIT_PRESSED);
return 0;
}
@@ -1237,7 +1233,7 @@ void control_config_button_pressed(int n)
Tab = n;
Scroll_offset = Selected_line = 0;
control_config_list_prepare();
gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
gamesnd_play_iface(InterfaceSounds::SCREEN_MODE_PRESSED);
break;
case BIND_BUTTON:
@@ -1250,17 +1246,17 @@ void control_config_button_pressed(int n)
case SHIFT_TOGGLE:
control_config_toggle_modifier(KEY_SHIFTED);
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
break;
case ALT_TOGGLE:
control_config_toggle_modifier(KEY_ALTED);
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
break;
case INVERT_AXIS:
control_config_toggle_invert();
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
break;
case SCROLL_UP_BUTTON:
@@ -1281,7 +1277,7 @@ void control_config_button_pressed(int n)
case HELP_BUTTON:
launch_context_help();
gamesnd_play_iface(SND_HELP_PRESSED);
gamesnd_play_iface(InterfaceSounds::HELP_PRESSED);
break;
case RESET_BUTTON:
@@ -1799,7 +1795,7 @@ void control_config_do_frame(float frametime)
Scroll_offset = Selected_line = 0;
control_config_list_prepare();
gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
gamesnd_play_iface(InterfaceSounds::SCREEN_MODE_PRESSED);
break;
case KEY_TAB: // activate next tab
@@ -1810,7 +1806,7 @@ void control_config_do_frame(float frametime)
Scroll_offset = Selected_line = 0;
control_config_list_prepare();
gamesnd_play_iface(SND_SCREEN_MODE_PRESSED);
gamesnd_play_iface(InterfaceSounds::SCREEN_MODE_PRESSED);
break;
case KEY_LEFT:
@@ -1825,7 +1821,7 @@ void control_config_do_frame(float frametime)
}
}
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
break;
case KEY_RIGHT:
@@ -1837,7 +1833,7 @@ void control_config_do_frame(float frametime)
} else if (Selected_item > 1) {
Selected_item = -1;
}
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
break;
case KEY_BACKSP: // undo
@@ -1873,7 +1869,7 @@ void control_config_do_frame(float frametime)
Selected_item = 1;
}
gamesnd_play_iface(SND_USER_SELECT);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
}
if (List_buttons[i].double_clicked()) {
@@ -1988,7 +1984,9 @@ void control_config_do_frame(float frametime)
gr_get_string_size(&w, NULL, str);
gr_printf_menu(x - w / 2, y - font_height, "%s", str);
if (Control_config[i].hasXSTR) {
if (Control_config[i].indexXSTR > 1) {
strcpy_s(buf, XSTR(Control_config[i].text, Control_config[i].indexXSTR));
} else if (Control_config[i].indexXSTR == 1) {
strcpy_s(buf, XSTR(Control_config[i].text, CONTROL_CONFIG_XSTR + i));
} else {
strcpy_s(buf, Control_config[i].text);
@@ -2193,17 +2191,6 @@ void control_config_do_frame(float frametime)
gr_flip();
}
void clear_key_binding(short key)
{
int i;
for (i=0; i<CCFG_MAX; i++) {
if (Control_config[i].key_id == key) {
Control_config[i].key_id = -1;
}
}
}
float check_control_timef(int id)
{
float t1, t2;
@@ -2317,7 +2304,7 @@ int check_control_used(int id, int key)
if ((Control_config[id].key_id == key) || joy_down_count(Control_config[id].joy_id, 1) ||
((Control_config[id].joy_id >= 0) && (Control_config[id].joy_id < MOUSE_NUM_BUTTONS) && mouse_down_count(1 << Control_config[id].joy_id))) {
//mprintf(("Key used %d", key));
//mprintf(("Key used %d\n", key));
control_used(id);
return 1;
}
@@ -2345,7 +2332,7 @@ int check_control(int id, int key)
// which has just been released
Script_system.SetHookVar("Action", 's', Control_config[id].text);
Script_system.RunCondition(CHA_ONACTIONSTOPPED, '\0', NULL, NULL, id);
Script_system.RunCondition(CHA_ONACTIONSTOPPED, nullptr, id);
Script_system.RemHookVar("Action");
Control_config[id].continuous_ongoing = false;
@@ -2379,7 +2366,7 @@ void control_get_axes_readings(int *h, int *p, int *b, int *ta, int *tr)
*ta = 0;
if (Axis_map_to[3] >= 0) {
*ta = joy_get_unscaled_reading(axes_values[Axis_map_to[3]], Axis_map_to[3]);
*ta = joy_get_unscaled_reading(axes_values[Axis_map_to[3]]);
}
*tr = 0;
@@ -2419,7 +2406,7 @@ void control_used(int id)
if (Control_config[id].used < Last_frame_timestamp) {
if (!Control_config[id].continuous_ongoing) {
Script_system.SetHookVar("Action", 's', Control_config[id].text);
Script_system.RunCondition(CHA_ONACTION, '\0', NULL, NULL, id);
Script_system.RunCondition(CHA_ONACTION, nullptr, id);
Script_system.RemHookVar("Action");
if (Control_config[id].type == CC_TYPE_CONTINUOUS)
@@ -2447,9 +2434,4 @@ void control_config_clear()
for (i=0; i<CCFG_MAX; i++) {
Control_config[i].key_id = Control_config[i].joy_id = -1;
}
}
int control_config_handle_conflict()
{
return 0;
}
}
+10 -8
View File
@@ -62,7 +62,7 @@ typedef struct config_item {
short key_default; //!< default key bound to action
short joy_default; //!< default joystick button bound to action
char tab; //!< what tab (category) it belongs in
bool hasXSTR; //!< whether we should translate this with an XSTR
int indexXSTR; //!< what string index we should use to translate this with an XSTR
const char *text; //!< describes the action in the config screen
char type; //!< manner control should be checked in
short key_id; //!< actual key bound to action
@@ -270,6 +270,15 @@ enum IoActionId {
//!< ----------------------------
CYCLE_PRIMARY_WEAPON_SEQUENCE =118, //!< cycle num primaries to fire at once
//!< @n
//!< Custom control slots
//!< ----------------------------
CUSTOM_CONTROL_1 = 119,
CUSTOM_CONTROL_2 = 120,
CUSTOM_CONTROL_3 = 121,
CUSTOM_CONTROL_4 = 122,
CUSTOM_CONTROL_5 = 123,
/*!
* This must always be below the last defined item
*/
@@ -277,12 +286,6 @@ enum IoActionId {
};
extern int Failed_key_index;
extern int Invert_heading;
extern int Invert_pitch;
extern int Invert_roll;
extern int Invert_thrust;
extern int Disable_axis2;
extern int Disable_axis3;
extern int Axis_map_to[];
extern int Invert_axis[];
@@ -336,7 +339,6 @@ int check_control(int id, int key = -1);
void control_get_axes_readings(int *h, int *p, int *b, int *ta, int *tr);
void control_used(int id);
void control_config_clear();
void clear_key_binding(short key);
void control_check_indicate();
void control_config_clear_used_status();
+156 -160
View File
@@ -7,8 +7,8 @@
*
*/
#include <stdio.h>
#include <stdarg.h>
#include <cstdio>
#include <cstdarg>
#include "cfile/cfile.h"
#include "controlconfig/controlsconfig.h"
@@ -17,6 +17,7 @@
#include "io/joy.h"
#include "io/key.h"
#include "localization/localize.h"
#include "options/Option.h"
#include "parse/parselo.h"
// z64: These enumerations MUST equal to those in controlsconfig.cpp...
@@ -32,15 +33,29 @@ int Failed_key_index;
// Joystick configuration
int Joy_dead_zone_size = 10;
auto DeadZoneOption =
options::OptionBuilder<int>("Input.JoystickDeadZone", "Deadzone", "The deadzone of the selected joystick.")
.category("Input")
.range(0, 45)
.level(options::ExpertLevel::Beginner)
.default_val(10)
.bind_to(&Joy_dead_zone_size)
.importance(1)
.finish();
int Joy_sensitivity = 9;
// assume control keys are used as modifiers until we find out
int Shift_is_modifier;
int Ctrl_is_modifier;
int Alt_is_modifier;
auto SensitivityOption =
options::OptionBuilder<int>("Input.JoystickSensitivity", "Sensitivity", "The sentitivity of the selected joystick.")
.category("Input")
.range(0, 9)
.level(options::ExpertLevel::Beginner)
.default_val(9)
.bind_to(&Joy_sensitivity)
.importance(2)
.finish();
int Axis_enabled[JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 };
int Axis_enabled_defaults[JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 };
int Invert_axis[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
int Invert_axis_defaults[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
@@ -49,159 +64,164 @@ int Invert_axis_defaults[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
//XSTR:OFF
config_item Control_config[CCFG_MAX + 1] = {
// targeting a ship
{ KEY_T, -1, TARGET_TAB, true, "Target Next Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_T, -1, TARGET_TAB, true, "Target Previous Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_H, 2, TARGET_TAB, true, "Target Next Closest Hostile Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_H, -1, TARGET_TAB, true, "Target Previous Closest Hostile Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_H, -1, TARGET_TAB, true, "Toggle Auto Targeting", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_F, -1, TARGET_TAB, true, "Target Next Closest Friendly Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_F, -1, TARGET_TAB, true, "Target Previous Closest Friendly Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_Y, 4, TARGET_TAB, true, "Target Ship in Reticle", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_G, -1, TARGET_TAB, true, "Target Target's Nearest Attacker", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_Y, -1, TARGET_TAB, true, "Target Last Ship to Send Transmission", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_T, -1, TARGET_TAB, true, "Turn Off Targeting", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_T, -1, TARGET_TAB, 1, "Target Next Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_T, -1, TARGET_TAB, 1, "Target Previous Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_H, 2, TARGET_TAB, 1, "Target Next Closest Hostile Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_H, -1, TARGET_TAB, 1, "Target Previous Closest Hostile Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_H, -1, TARGET_TAB, 1, "Toggle Auto Targeting", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_F, -1, TARGET_TAB, 1, "Target Next Closest Friendly Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_F, -1, TARGET_TAB, 1, "Target Previous Closest Friendly Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_Y, 4, TARGET_TAB, 1, "Target Ship in Reticle", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_G, -1, TARGET_TAB, 1, "Target Target's Nearest Attacker", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_Y, -1, TARGET_TAB, 1, "Target Last Ship to Send Transmission", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_T, -1, TARGET_TAB, 1, "Turn Off Targeting", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
// targeting a ship's subsystem
{ KEY_V, -1, TARGET_TAB, true, "Target Subsystem in Reticle", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_S, -1, TARGET_TAB, true, "Target Next Subsystem", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_S, -1, TARGET_TAB, true, "Target Previous Subsystem", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_S, -1, TARGET_TAB, true, "Turn Off Targeting of Subsystems", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_V, -1, TARGET_TAB, 1, "Target Subsystem in Reticle", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_S, -1, TARGET_TAB, 1, "Target Next Subsystem", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_S, -1, TARGET_TAB, 1, "Target Previous Subsystem", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_S, -1, TARGET_TAB, 1, "Turn Off Targeting of Subsystems", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
// matching speed
{ KEY_M, -1, COMPUTER_TAB, true, "Match Target Speed", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_M, -1, COMPUTER_TAB, true, "Toggle Auto Speed Matching", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_M, -1, COMPUTER_TAB, 1, "Match Target Speed", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_M, -1, COMPUTER_TAB, 1, "Toggle Auto Speed Matching", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
// weapons
{ KEY_LCTRL, 0, WEAPON_TAB, true, "Fire Primary Weapon", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_SPACEBAR, 1, WEAPON_TAB, true, "Fire Secondary Weapon", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PERIOD, -1, WEAPON_TAB, true, "Cycle Forward Primary Weapon", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_COMMA, -1, WEAPON_TAB, true, "Cycle Backward Primary Weapon", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_DIVIDE, -1, WEAPON_TAB, true, "Cycle Secondary Weapon Bank", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_DIVIDE, -1, WEAPON_TAB, true, "Cycle Secondary Weapon Firing Rate", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_X, 3, WEAPON_TAB, true, "Launch Countermeasure", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_LCTRL, 0, WEAPON_TAB, 1, "Fire Primary Weapon", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_SPACEBAR, 1, WEAPON_TAB, 1, "Fire Secondary Weapon", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PERIOD, -1, WEAPON_TAB, 1, "Cycle Forward Primary Weapon", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_COMMA, -1, WEAPON_TAB, 1, "Cycle Backward Primary Weapon", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_DIVIDE, -1, WEAPON_TAB, 1, "Cycle Secondary Weapon Bank", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_DIVIDE, -1, WEAPON_TAB, 1, "Cycle Secondary Weapon Firing Rate", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_X, 3, WEAPON_TAB, 1, "Launch Countermeasure", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
// controls
{ KEY_A, -1, SHIP_TAB, true, "Forward Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_Z, -1, SHIP_TAB, true, "Reverse Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD7, -1, SHIP_TAB, true, "Bank Left", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD9, -1, SHIP_TAB, true, "Bank Right", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD8, -1, SHIP_TAB, true, "Pitch Forward", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD2, -1, SHIP_TAB, true, "Pitch Backward", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD4, -1, SHIP_TAB, true, "Turn Left", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD6, -1, SHIP_TAB, true, "Turn Right", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_A, -1, SHIP_TAB, 1, "Forward Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_Z, -1, SHIP_TAB, 1, "Reverse Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD7, -1, SHIP_TAB, 1, "Bank Left", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD9, -1, SHIP_TAB, 1, "Bank Right", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD8, -1, SHIP_TAB, 1, "Pitch Forward", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD2, -1, SHIP_TAB, 1, "Pitch Backward", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD4, -1, SHIP_TAB, 1, "Turn Left", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD6, -1, SHIP_TAB, 1, "Turn Right", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
// throttle controls
{ KEY_BACKSP, -1, SHIP_TAB, true, "Set Throttle to Zero", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SLASH, -1, SHIP_TAB, true, "Set Throttle to Max", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_LBRACKET, -1, SHIP_TAB, true, "Set Throttle to One-Third", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_RBRACKET, -1, SHIP_TAB, true, "Set Throttle to Two-Thirds", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_EQUAL, -1, SHIP_TAB, true, "Increase Throttle 5 Percent", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_MINUS, -1, SHIP_TAB, true, "Decrease Throttle 5 Percent", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_BACKSP, -1, SHIP_TAB, 1, "Set Throttle to Zero", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SLASH, -1, SHIP_TAB, 1, "Set Throttle to Max", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_LBRACKET, -1, SHIP_TAB, 1, "Set Throttle to One-Third", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_RBRACKET, -1, SHIP_TAB, 1, "Set Throttle to Two-Thirds", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_EQUAL, -1, SHIP_TAB, 1, "Increase Throttle 5 Percent", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_MINUS, -1, SHIP_TAB, 1, "Decrease Throttle 5 Percent", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
// squadmate messaging
{ KEY_SHIFTED | KEY_A, -1, COMPUTER_TAB, true, "Attack My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_Z, -1, COMPUTER_TAB, true, "Disarm My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_D, -1, COMPUTER_TAB, true, "Disable My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_V, -1, COMPUTER_TAB, true, "Attack My Subsystem", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_X, -1, COMPUTER_TAB, true, "Capture My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, true, "Engage Enemy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_W, -1, COMPUTER_TAB, true, "Form on My Wing", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_I, -1, COMPUTER_TAB, true, "Ignore My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_P, -1, COMPUTER_TAB, true, "Protect My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_C, -1, COMPUTER_TAB, true, "Cover Me", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_J, -1, COMPUTER_TAB, true, "Return to Base", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_R, -1, COMPUTER_TAB, true, "Rearm Me", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_A, -1, COMPUTER_TAB, 1, "Attack My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_Z, -1, COMPUTER_TAB, 1, "Disarm My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_D, -1, COMPUTER_TAB, 1, "Disable My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_V, -1, COMPUTER_TAB, 1, "Attack My Subsystem", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_X, -1, COMPUTER_TAB, 1, "Capture My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, 1, "Engage Enemy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_W, -1, COMPUTER_TAB, 1, "Form on My Wing", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_I, -1, COMPUTER_TAB, 1, "Ignore My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_P, -1, COMPUTER_TAB, 1, "Protect My Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_C, -1, COMPUTER_TAB, 1, "Cover Me", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_J, -1, COMPUTER_TAB, 1, "Return to Base", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_R, -1, COMPUTER_TAB, 1, "Rearm Me", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_R, 6, TARGET_TAB, true, "Target Closest Attacking Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_R, 6, TARGET_TAB, 1, "Target Closest Attacking Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
// Views
{ KEY_PADMULTIPLY, -1, COMPUTER_TAB, true, "Chase View", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PADPERIOD, -1, COMPUTER_TAB, true, "External View", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PADENTER, -1, COMPUTER_TAB, true, "Toggle External Camera Lock", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PAD0, -1, COMPUTER_TAB, true, "Free Look View", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false }, // Not in use anymore (Swifty)
{ KEY_PADDIVIDE, -1, COMPUTER_TAB, true, "Current Target View", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PADPLUS, -1, COMPUTER_TAB, true, "Increase View Distance", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PADMINUS, -1, COMPUTER_TAB, true, "Decrease View Distance", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD5, -1, COMPUTER_TAB, true, "Center View", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ -1, 33, COMPUTER_TAB, true, "View Up", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ -1, 32, COMPUTER_TAB, true, "View Rear", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ -1, 34, COMPUTER_TAB, true, "View Left", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ -1, 35, COMPUTER_TAB, true, "View Right", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PADMULTIPLY, -1, COMPUTER_TAB, 1, "Chase View", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PADPERIOD, -1, COMPUTER_TAB, 1, "External View", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PADENTER, -1, COMPUTER_TAB, 1, "Toggle External Camera Lock", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PAD0, -1, COMPUTER_TAB, 1, "Free Look View", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PADDIVIDE, -1, COMPUTER_TAB, 1, "Current Target View", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PADPLUS, -1, COMPUTER_TAB, 1, "Increase View Distance", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PADMINUS, -1, COMPUTER_TAB, 1, "Decrease View Distance", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_PAD5, -1, COMPUTER_TAB, 1, "Center View", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ -1, 33, COMPUTER_TAB, 1, "View Up", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ -1, 32, COMPUTER_TAB, 1, "View Rear", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ -1, 34, COMPUTER_TAB, 1, "View Left", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ -1, 35, COMPUTER_TAB, 1, "View Right", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_RAPOSTRO, -1, COMPUTER_TAB, true, "Cycle Radar Range", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_C, -1, COMPUTER_TAB, true, "Communications Menu", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ -1, -1, -1, true, "Show Objectives", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_J, -1, COMPUTER_TAB, true, "Enter Subspace (End Mission)", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_J, -1, TARGET_TAB, true, "Target Target's Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_TAB, 5, SHIP_TAB, true, "Afterburner", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_RAPOSTRO, -1, COMPUTER_TAB, 1, "Cycle Radar Range", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_C, -1, COMPUTER_TAB, 1, "Communications Menu", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ -1, -1, -1, 1, "Show Objectives", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_J, -1, COMPUTER_TAB, 1, "Enter Subspace (End Mission)", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_J, -1, TARGET_TAB, 1, "Target Target's Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_TAB, 5, SHIP_TAB, 1, "Afterburner", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_INSERT, -1, COMPUTER_TAB, true, "Increase Weapon Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_DELETE, -1, COMPUTER_TAB, true, "Decrease Weapon Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_HOME, -1, COMPUTER_TAB, true, "Increase Shield Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_END, -1, COMPUTER_TAB, true, "Decrease Shield Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PAGEUP, -1, COMPUTER_TAB, true, "Increase Engine Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PAGEDOWN, -1, COMPUTER_TAB, true, "Decrease Engine Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_D, -1, COMPUTER_TAB, true, "Equalize Energy Settings", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_INSERT, -1, COMPUTER_TAB, 1, "Increase Weapon Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_DELETE, -1, COMPUTER_TAB, 1, "Decrease Weapon Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_HOME, -1, COMPUTER_TAB, 1, "Increase Shield Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_END, -1, COMPUTER_TAB, 1, "Decrease Shield Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PAGEUP, -1, COMPUTER_TAB, 1, "Increase Engine Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_PAGEDOWN, -1, COMPUTER_TAB, 1, "Decrease Engine Energy", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_D, -1, COMPUTER_TAB, 1, "Equalize Energy Settings", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_Q, 7, COMPUTER_TAB, true, "Equalize Shields", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_UP, -1, COMPUTER_TAB, true, "Augment Forward Shield", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_DOWN, -1, COMPUTER_TAB, true, "Augment Rear Shield", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_LEFT, -1, COMPUTER_TAB, true, "Augment Left Shield", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_RIGHT, -1, COMPUTER_TAB, true, "Augment Right Shield", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SCROLLOCK, -1, COMPUTER_TAB, true, "Transfer Energy Laser->Shield", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_SCROLLOCK, -1, COMPUTER_TAB, true, "Transfer Energy Shield->Laser", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_Q, 7, COMPUTER_TAB, 1, "Equalize Shields", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_UP, -1, COMPUTER_TAB, 1, "Augment Forward Shield", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_DOWN, -1, COMPUTER_TAB, 1, "Augment Rear Shield", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_LEFT, -1, COMPUTER_TAB, 1, "Augment Left Shield", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_RIGHT, -1, COMPUTER_TAB, 1, "Augment Right Shield", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SCROLLOCK, -1, COMPUTER_TAB, 1, "Transfer Energy Laser->Shield", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_SCROLLOCK, -1, COMPUTER_TAB, 1, "Transfer Energy Shield->Laser", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
// { -1, -1, -1, true, "Show Damage Popup Window" },
{ -1, -1, SHIP_TAB, false, "Glide When Pressed", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ -1, -1, SHIP_TAB, 0, "Glide When Pressed", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
//Backslash -- this was a convenient place for Glide When Pressed, as Show Damage Popup isn't used
{ -1, -1, SHIP_TAB, true, "Bank When Pressed", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ -1, -1, -1, true, "Show Nav Map", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_E, -1, COMPUTER_TAB, true, "Add or Remove Escort", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, true, "Clear Escort List", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_E, -1, TARGET_TAB, true, "Target Next Escort Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_R, -1, TARGET_TAB, true, "Target Closest Repair Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ -1, -1, SHIP_TAB, 1, "Bank When Pressed", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ -1, -1, -1, 1, "Show Nav Map", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_E, -1, COMPUTER_TAB, 1, "Add or Remove Escort", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, 1, "Clear Escort List", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_E, -1, TARGET_TAB, 1, "Target Next Escort Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_R, -1, TARGET_TAB, 1, "Target Closest Repair Ship", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_U, -1, TARGET_TAB, true, "Target Next Uninspected Cargo", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_U, -1, TARGET_TAB, true, "Target Previous Uninspected Cargo", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_N, -1, TARGET_TAB, true, "Target Newest Ship in Area", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_K, -1, TARGET_TAB, true, "Target Next Live Turret", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_K, -1, TARGET_TAB, true, "Target Previous Live Turret", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_U, -1, TARGET_TAB, 1, "Target Next Uninspected Cargo", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_U, -1, TARGET_TAB, 1, "Target Previous Uninspected Cargo", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_N, -1, TARGET_TAB, 1, "Target Newest Ship in Area", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_K, -1, TARGET_TAB, 1, "Target Next Live Turret", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_K, -1, TARGET_TAB, 1, "Target Previous Live Turret", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_B, -1, TARGET_TAB, true, "Target Next Hostile Bomb or Bomber", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_B, -1, TARGET_TAB, true, "Target Previous Hostile Bomb or Bomber", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_B, -1, TARGET_TAB, 1, "Target Next Hostile Bomb or Bomber", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_B, -1, TARGET_TAB, 1, "Target Previous Hostile Bomb or Bomber", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
// multiplayer messaging keys
{ KEY_1, -1, COMPUTER_TAB, true, "(Multiplayer) Message All", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_2, -1, COMPUTER_TAB, true, "(Multiplayer) Message Friendly", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_3, -1, COMPUTER_TAB, true, "(Multiplayer) Message Hostile", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_4, -1, COMPUTER_TAB, true, "(Multiplayer) Message Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_X, -1, COMPUTER_TAB, true, "(Multiplayer) Observer Zoom to Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_PERIOD, -1, COMPUTER_TAB, true, "Increase Time Compression", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_COMMA, -1, COMPUTER_TAB, true, "Decrease Time Compression", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_L, -1, COMPUTER_TAB, true, "Toggle High HUD Contrast", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_N, -1, COMPUTER_TAB, true, "(Multiplayer) Toggle Network Info", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_END, -1, COMPUTER_TAB, true, "(Multiplayer) Self Destruct", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_1, -1, COMPUTER_TAB, 1, "(Multiplayer) Message All", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_2, -1, COMPUTER_TAB, 1, "(Multiplayer) Message Friendly", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_3, -1, COMPUTER_TAB, 1, "(Multiplayer) Message Hostile", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_4, -1, COMPUTER_TAB, 1, "(Multiplayer) Message Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_X, -1, COMPUTER_TAB, 1, "(Multiplayer) Observer Zoom to Target", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_PERIOD, -1, COMPUTER_TAB, 1, "Increase Time Compression", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_COMMA, -1, COMPUTER_TAB, 1, "Decrease Time Compression", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_L, -1, COMPUTER_TAB, 1, "Toggle High HUD Contrast", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_N, -1, COMPUTER_TAB, 1, "(Multiplayer) Toggle Network Info", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_END, -1, COMPUTER_TAB, 1, "(Multiplayer) Self Destruct", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
// Misc
{ KEY_SHIFTED | KEY_O, -1, COMPUTER_TAB, true, "Toggle HUD", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_3, -1, SHIP_TAB, true, "Right Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_1, -1, SHIP_TAB, true, "Left Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_PADPLUS, -1, SHIP_TAB, true, "Up Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_PADENTER, -1, SHIP_TAB, true, "Down Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_SHIFTED | KEY_Q, -1, COMPUTER_TAB, true, "Toggle HUD Wireframe Target View", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ -1, -1, COMPUTER_TAB, false, "Top-Down View", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ -1, -1, COMPUTER_TAB, false, "Target Padlock View", CC_TYPE_TRIGGER, -1, -1, 0, false, false }, // (Swifty) Toggle for VM_TRACK
{ KEY_SHIFTED | KEY_O, -1, COMPUTER_TAB, 1, "Toggle HUD", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_3, -1, SHIP_TAB, 1, "Right Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_1, -1, SHIP_TAB, 1, "Left Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_PADPLUS, -1, SHIP_TAB, 1, "Up Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_SHIFTED | KEY_PADENTER, -1, SHIP_TAB, 1, "Down Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_SHIFTED | KEY_Q, -1, COMPUTER_TAB, 1, "Toggle HUD Wireframe Target View", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ -1, -1, COMPUTER_TAB, 0, "Top-Down View", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ -1, -1, COMPUTER_TAB, 0, "Target Padlock View", CC_TYPE_TRIGGER, -1, -1, 0, false, false }, // (Swifty) Toggle for VM_TRACK
// Auto Navigation Systen
{ KEY_ALTED | KEY_A, -1, COMPUTER_TAB, false, "Toggle Auto Pilot", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_N, -1, COMPUTER_TAB, false, "Cycle Nav Points", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_G, -1, SHIP_TAB, false, "Toggle Gliding", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_O, -1, WEAPON_TAB, false, "Cycle Primary Weapon Firing Rate", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ -1, -1, -1, false, "", CC_TYPE_TRIGGER, -1, -1, 0, false, false }
{ KEY_ALTED | KEY_A, -1, COMPUTER_TAB, 0, "Toggle Auto Pilot", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_N, -1, COMPUTER_TAB, 0, "Cycle Nav Points", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_G, -1, SHIP_TAB, 0, "Toggle Gliding", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_O, -1, WEAPON_TAB, 0, "Cycle Primary Weapon Firing Rate", CC_TYPE_TRIGGER, -1, -1, 0, false, false },
{ KEY_ALTED | KEY_SHIFTED | KEY_1, -1, COMPUTER_TAB, 0, "Custom Control 1", CC_TYPE_TRIGGER, -1, -1, 0, true, false },
{ KEY_ALTED | KEY_SHIFTED | KEY_2, -1, COMPUTER_TAB, 0, "Custom Control 2", CC_TYPE_TRIGGER, -1, -1, 0, true, false },
{ KEY_ALTED | KEY_SHIFTED | KEY_3, -1, COMPUTER_TAB, 0, "Custom Control 3", CC_TYPE_TRIGGER, -1, -1, 0, true, false },
{ KEY_ALTED | KEY_SHIFTED | KEY_4, -1, COMPUTER_TAB, 0, "Custom Control 4", CC_TYPE_TRIGGER, -1, -1, 0, true, false },
{ KEY_ALTED | KEY_SHIFTED | KEY_5, -1, COMPUTER_TAB, 0, "Custom Control 5", CC_TYPE_TRIGGER, -1, -1, 0, true, false },
{ -1, -1, -1, 0, "", CC_TYPE_TRIGGER, -1, -1, 0, false, false }
};
const char *Scan_code_text_german[] = {
"", "Esc", "1", "2", "3", "4", "5", "6",
"7", "8", "9", "0", "Akzent '", "Eszett", "R\x81""cktaste", "Tab",
"7", "8", "9", "0", "Akzent '", "Eszett", "R\x81""cktaste", "Tab", // NOLINT
"Q", "W", "E", "R", "T", "Z", "U", "I",
"O", "P", "\x9A", "+", "Eingabe", "Strg Links", "A", "S",
@@ -251,8 +271,8 @@ const char *Joy_button_text_german[] = {
};
const char *Scan_code_text_french[] = {
"", "\x90""chap", "1", "2", "3", "4", "5", "6",
"7", "8", "9", "0", "-", "=", "Fl\x82""che Ret.", "Tab",
"", "\x90""chap", "1", "2", "3", "4", "5", "6", // NOLINT
"7", "8", "9", "0", "-", "=", "Fl\x82""che Ret.", "Tab", // NOLINT
"Q", "W", "E", "R", "T", "Y", "U", "I",
"O", "P", "[", "]", "Entr\x82""e", "Ctrl Gauche", "A", "S",
@@ -410,31 +430,6 @@ const char **Joy_button_text = Joy_button_text_english;
SCP_vector<config_item*> Control_config_presets;
SCP_vector<SCP_string> Control_config_preset_names;
void set_modifier_status()
{
int i;
Alt_is_modifier = 0;
Shift_is_modifier = 0;
Ctrl_is_modifier = 0;
for (i=0; i<CCFG_MAX; i++) {
if (Control_config[i].key_id < 0)
continue;
if (Control_config[i].key_id & KEY_ALTED)
Alt_is_modifier = 1;
if (Control_config[i].key_id & KEY_SHIFTED)
Shift_is_modifier = 1;
if (Control_config[i].key_id & KEY_CTRLED) {
Assert(0); // get Alan
Ctrl_is_modifier = 1;
}
}
}
// If find_override is set to true, then this returns the index of the action
// which has been bound to the given key. Otherwise, the index of the action
// which has the given key as its default key will be returned.
@@ -536,7 +531,9 @@ char *translate_key(char *key)
// both key and joystick button are mapped to this control
if ((key_code >= 0 ) && (joy_code >= 0) ) {
strcpy_s(text, key_text);
strcat_s(text, " or ");
strcat_s(text, " ");
strcat_s(text, XSTR("or", 1638));
strcat_s(text, " ");
strcat_s(text, joy_text);
}
// if we only have one
@@ -616,7 +613,6 @@ void control_config_common_load_overrides();
void control_config_common_init()
{
for (int i=0; i<CCFG_MAX; i++) {
Control_config[i].disabled = false;
Control_config[i].continuous_ongoing = false;
}
@@ -873,7 +869,7 @@ void control_config_common_load_overrides()
* short key_default;
* short joy_default;
* char tab;
* bool hasXSTR;
* int indexXSTR;
* char type;
*/
@@ -915,7 +911,7 @@ void control_config_common_load_overrides()
if (optional_string("$Has XStr:")) {
stuff_int(&iTemp);
r_ccConfig.hasXSTR = (iTemp == 1);
r_ccConfig.indexXSTR = iTemp;
}
if (optional_string("$Type:")) {
+6 -11
View File
@@ -3,6 +3,12 @@
#include <memory>
namespace cutscene {
FrameSize::FrameSize(size_t in_width, size_t in_height, size_t in_stride)
: width(in_width), height(in_height), stride(in_stride)
{
}
FrameSize::FrameSize() = default;
Decoder::Decoder() : m_decoding(true) {
}
@@ -40,10 +46,6 @@ void Decoder::stopDecoder() {
m_subtitleQueue->close();
}
bool Decoder::canPushAudioData() {
return !isAudioQueueFull();
}
void Decoder::pushAudioData(AudioFramePtr&& data) {
Assertion(data, "Invalid audio data passed!");
@@ -55,9 +57,6 @@ void Decoder::pushAudioData(AudioFramePtr&& data) {
}
}
bool Decoder::canPushSubtitleData() {
return !isSubtitleQueueFull();
}
void Decoder::pushSubtitleData(SubtitleFramePtr&& data) {
Assertion(data, "Invalid audio data passed!");
@@ -69,10 +68,6 @@ void Decoder::pushSubtitleData(SubtitleFramePtr&& data) {
}
}
bool Decoder::canPushVideoData() {
return !isVideoQueueFull();
}
void Decoder::pushFrameData(VideoFramePtr&& frame) {
Assertion(frame, "Invalid video data passed!");
+27 -25
View File
@@ -10,28 +10,26 @@ struct FrameSize {
size_t width = 0;
size_t height = 0;
size_t stride = 0;
FrameSize();
FrameSize(size_t width, size_t in_height, size_t in_stride);
};
class VideoFrame {
protected:
VideoFrame() {}
VideoFrame() = default;
public:
virtual ~VideoFrame() {}
public:
virtual ~VideoFrame() = default;
double frameTime = -1.0;
int id = -1;
FrameSize ySize;
FrameSize uvSize;
virtual size_t getPlaneNumber() = 0;
struct DataPointers {
ubyte* y;
ubyte* u;
ubyte* v;
};
virtual FrameSize getPlaneSize(size_t plane) = 0;
virtual DataPointers getDataPointers() = 0;
virtual void* getPlaneData(size_t plane) = 0;
};
/**
@@ -43,10 +41,19 @@ using FramePtr = std::unique_ptr<T>;
typedef std::unique_ptr<VideoFrame> VideoFramePtr;
enum class FramePixelFormat {
Invalid,
YUV420,
BGR,
BGRA
};
struct MovieProperties {
FrameSize size;
float fps = -1.0f;
FramePixelFormat pixelFormat = FramePixelFormat::Invalid;
};
struct AudioFrame {
@@ -66,6 +73,11 @@ struct SubtitleFrame {
};
typedef std::unique_ptr<SubtitleFrame> SubtitleFramePtr;
struct PlaybackProperties {
bool with_audio = true;
bool looping = false;
};
/**
* @brief Abstract class for decoding a video or audio stream
*
@@ -99,13 +111,13 @@ class Decoder {
* @param fileName The name of the file that should be opened
* @return @c true if the initialization was successfull, @c false otherwise
*/
virtual bool initialize(const SCP_string& fileName) = 0;
virtual bool initialize(const SCP_string& fileName, const PlaybackProperties& properties) = 0;
/**
* @brief Returns the properties of the video
* @return The properties
*/
virtual MovieProperties getProperties() = 0;
virtual MovieProperties getProperties() const = 0;
/**
* @brief Starts decoding the video
@@ -116,9 +128,9 @@ class Decoder {
* @brief Determines if the video has audio
* @return @c true if audio is included in the video
*/
virtual bool hasAudio() = 0;
virtual bool hasAudio() const = 0;
virtual bool hasSubtitles() = 0;
virtual bool hasSubtitles() const = 0;
/**
* @brief Ends decoding of the video file
@@ -135,10 +147,6 @@ class Decoder {
bool isSubtitleQueueFull() { return m_subtitleQueue->size() == m_queueSize; }
bool isSubtitleFrameAvailable() { return !m_subtitleQueue->empty(); }
size_t getSubtitleQueueSize() { return m_subtitleQueue->size(); }
bool tryPopSubtitleData(SubtitleFramePtr&);
bool isVideoQueueFull() { return m_videoQueue->size() == m_queueSize; }
@@ -156,16 +164,10 @@ class Decoder {
protected:
void initializeQueues(size_t queueSize);
bool canPushAudioData();
void pushAudioData(AudioFramePtr&& data);
bool canPushSubtitleData();
void pushSubtitleData(SubtitleFramePtr&& data);
bool canPushVideoData();
void pushFrameData(VideoFramePtr&& frame);
};
}
+67 -24
View File
@@ -14,46 +14,85 @@ struct movie_vertex {
namespace cutscene {
namespace player {
VideoPresenter::VideoPresenter(const MovieProperties& props) {
VideoPresenter::VideoPresenter(const MovieProperties& props) : _properties(props)
{
GR_DEBUG_SCOPE("Init video");
_planeTextureHandles.fill(-1);
auto w = static_cast<int>(props.size.width);
auto h = static_cast<int>(props.size.height);
// Create buffer textures
_yTexBuffer.reset(new uint8_t[w * h]);
_ytex = bm_create(8, w, h, _yTexBuffer.get(), BMP_AABITMAP);
switch (props.pixelFormat) {
case FramePixelFormat::YUV420:
_planeTextureBuffers[0].reset(new uint8_t[w * h]);
_planeTextureHandles[0] = bm_create(8, w, h, _planeTextureBuffers[0].get(), BMP_AABITMAP);
_uTexBuffer.reset(new uint8_t[w / 2 * h / 2]);
_utex = bm_create(8, w / 2, h / 2, _uTexBuffer.get(), BMP_AABITMAP);
_planeTextureBuffers[1].reset(new uint8_t[w / 2 * h / 2]);
_planeTextureHandles[1] = bm_create(8, w / 2, h / 2, _planeTextureBuffers[1].get(), BMP_AABITMAP);
_vTexBuffer.reset(new uint8_t[w / 2 * h / 2]);
_vtex = bm_create(8, w / 2, h / 2, _vTexBuffer.get(), BMP_AABITMAP);
_planeTextureBuffers[2].reset(new uint8_t[w / 2 * h / 2]);
_planeTextureHandles[2] = bm_create(8, w / 2, h / 2, _planeTextureBuffers[2].get(), BMP_AABITMAP);
material_set_movie(&_render_material, _ytex, _utex, _vtex);
material_set_movie(&_movie_material, _planeTextureHandles[0], _planeTextureHandles[1], _planeTextureHandles[2]);
break;
case FramePixelFormat::BGR:
_planeTextureBuffers[0].reset(new uint8_t[w * h * 3]);
_planeTextureHandles[0] = bm_create(24, w, h, _planeTextureBuffers[0].get(), 0);
material_set_unlit(&_rgb_material, _planeTextureHandles[0], 1.0f, false, false);
break;
case FramePixelFormat::BGRA:
_planeTextureBuffers[0].reset(new uint8_t[w * h * 4]);
_planeTextureHandles[0] = bm_create(32, w, h, _planeTextureBuffers[0].get(), 0);
material_set_unlit(&_rgb_material, _planeTextureHandles[0], 1.0f, true, false);
break;
default:
UNREACHABLE("Unhandled enum value!");
break;
}
}
VideoPresenter::~VideoPresenter() {
GR_DEBUG_SCOPE("Deinit video");
bm_release(_ytex);
bm_release(_utex);
bm_release(_vtex);
_ytex = _utex = _vtex = -1;
for (auto& handle : _planeTextureHandles) {
if (handle > 0) {
bm_release(handle);
handle = -1;
}
}
}
void VideoPresenter::uploadVideoFrame(const VideoFramePtr& frame) {
GR_DEBUG_SCOPE("Update video frame");
auto ptrs = frame->getDataPointers();
memcpy(_yTexBuffer.get(), ptrs.y, frame->ySize.stride * frame->ySize.height);
memcpy(_uTexBuffer.get(), ptrs.u, frame->uvSize.stride * frame->uvSize.height);
memcpy(_vTexBuffer.get(), ptrs.v, frame->uvSize.stride * frame->uvSize.height);
for (size_t i = 0; i < frame->getPlaneNumber(); ++i) {
auto size = frame->getPlaneSize(i);
auto data = frame->getPlaneData(i);
gr_update_texture(_ytex, 8, _yTexBuffer.get(), (int) frame->ySize.width, (int) frame->ySize.height);
gr_update_texture(_utex, 8, _uTexBuffer.get(), (int) frame->uvSize.width, (int) frame->uvSize.height);
gr_update_texture(_vtex, 8, _vTexBuffer.get(), (int) frame->uvSize.width, (int) frame->uvSize.height);
memcpy(_planeTextureBuffers[i].get(), data, size.stride * size.height);
int bpp = 0;
switch (_properties.pixelFormat) {
case FramePixelFormat::YUV420:
bpp = 8;
break;
case FramePixelFormat::BGR:
bpp = 24;
break;
case FramePixelFormat::BGRA:
bpp = 32;
break;
default:
UNREACHABLE("Unhandled enum value!");
break;
}
gr_update_texture(_planeTextureHandles[i], bpp, _planeTextureBuffers[i].get(), static_cast<int>(size.width),
static_cast<int>(size.height));
}
}
void VideoPresenter::displayFrame(float x1, float y1, float x2, float y2) {
@@ -85,10 +124,14 @@ void VideoPresenter::displayFrame(float x1, float y1, float x2, float y2) {
auto offset = gr_add_to_immediate_buffer(sizeof(vertex_data), vertex_data);
vertex_layout layout;
layout.add_vertex_component(vertex_format_data::POSITION2, sizeof(vertex_data[0]), offset + offsetof(movie_vertex, pos));
layout.add_vertex_component(vertex_format_data::TEX_COORD2, sizeof(vertex_data[0]), offset + offsetof(movie_vertex, uv));
layout.add_vertex_component(vertex_format_data::POSITION2, sizeof(vertex_data[0]), offsetof(movie_vertex, pos));
layout.add_vertex_component(vertex_format_data::TEX_COORD2, sizeof(vertex_data[0]), offsetof(movie_vertex, uv));
gr_render_movie(&_render_material, PRIM_TYPE_TRISTRIP, &layout, 4, gr_immediate_buffer_handle);
if (_properties.pixelFormat == FramePixelFormat::YUV420) {
gr_render_movie(&_movie_material, PRIM_TYPE_TRISTRIP, &layout, 4, gr_immediate_buffer_handle, offset);
} else {
gr_render_primitives(&_rgb_material, PRIM_TYPE_TRISTRIP, &layout, 0, 4, gr_immediate_buffer_handle, offset);
}
}
}
+5 -8
View File
@@ -12,16 +12,13 @@ namespace cutscene {
namespace player {
class VideoPresenter {
int _ytex = -1;
std::unique_ptr<uint8_t[]> _yTexBuffer;
MovieProperties _properties;
int _utex = -1;
std::unique_ptr<uint8_t[]> _uTexBuffer;
std::array<int, 3> _planeTextureHandles;
std::array<std::unique_ptr<uint8_t[]>, 3> _planeTextureBuffers;
int _vtex = -1;
std::unique_ptr<uint8_t[]> _vTexBuffer;
movie_material _render_material;
movie_material _movie_material;
material _rgb_material; // Material used when a RGB/RGBA movie is played
public:
explicit VideoPresenter(const MovieProperties& props);
+30 -21
View File
@@ -83,24 +83,33 @@ void cutscene_init()
if (optional_string("$cd:"))
{
// Option isn't needed anymore. Consume the token and ignore it
// CD option isn't needed anymore. Consume the token and ignore it
int junk;
stuff_int(&junk);
}
cutinfo.viewable = false;
cutinfo.flags.reset();
if (isFirstCutscene)
{
isFirstCutscene = false;
// The original code assumes the first movie is the intro, so always viewable
cutinfo.viewable = true;
// The original code assumes the first movie is the intro, so make it viewable
cutinfo.flags.set(Cutscene::Cutscene_Flags::Viewable);
}
if (optional_string("$Always Viewable:"))
{
stuff_boolean(&cutinfo.viewable);
bool flag;
stuff_boolean(&flag);
if (flag)
cutinfo.flags.set(Cutscene::Cutscene_Flags::Always_viewable);
}
if (optional_string("$Never Viewable:"))
{
bool flag;
stuff_boolean(&flag);
if (flag)
cutinfo.flags.set(Cutscene::Cutscene_Flags::Never_viewable);
}
Cutscenes.push_back(cutinfo);
@@ -143,7 +152,7 @@ void cutscene_mark_viewable(const char* filename)
// see if the stripped filename matches the cutscene filename
if (strstr(cut_file, file) != NULL)
{
cut->viewable = true;
cut->flags.set(Cutscene::Cutscene_Flags::Viewable);
return;
}
i++;
@@ -286,10 +295,10 @@ void cutscenes_screen_scroll_line_up()
if (Selected_line)
{
Selected_line--;
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
} else
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
if (Selected_line < Scroll_offset)
Scroll_offset = Selected_line;
@@ -302,10 +311,10 @@ void cutscenes_screen_scroll_line_down()
if (Selected_line < (int) Cutscene_list.size() - 1)
{
Selected_line++;
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
} else
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
h = Cutscene_list_coords[gr_screen.res][3] / gr_get_font_height();
if (Selected_line >= Scroll_offset + h)
@@ -328,11 +337,11 @@ void cutscenes_screen_scroll_screen_up()
Selected_line--;
}
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
} else
{
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
}
}
@@ -349,10 +358,10 @@ void cutscenes_screen_scroll_screen_down()
Selected_line = Scroll_offset;
}
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
} else
{
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
}
}
@@ -361,17 +370,17 @@ int cutscenes_screen_button_pressed(int n)
switch (n)
{
case TECH_DATABASE_BUTTON:
gamesnd_play_iface(SND_SWITCH_SCREENS);
gamesnd_play_iface(InterfaceSounds::SWITCH_SCREENS);
gameseq_post_event(GS_EVENT_TECH_MENU);
return 1;
case SIMULATOR_BUTTON:
gamesnd_play_iface(SND_SWITCH_SCREENS);
gamesnd_play_iface(InterfaceSounds::SWITCH_SCREENS);
gameseq_post_event(GS_EVENT_SIMULATOR_ROOM);
return 1;
case CREDITS_BUTTON:
gamesnd_play_iface(SND_SWITCH_SCREENS);
gamesnd_play_iface(InterfaceSounds::SWITCH_SCREENS);
gameseq_post_event(GS_EVENT_CREDITS);
return 1;
@@ -388,7 +397,7 @@ int cutscenes_screen_button_pressed(int n)
break;
case EXIT_BUTTON:
gamesnd_play_iface(SND_COMMIT_PRESSED);
gamesnd_play_iface(InterfaceSounds::COMMIT_PRESSED);
gameseq_post_event(GS_EVENT_MAIN_MENU);
game_flush();
break;
@@ -441,9 +450,9 @@ void cutscenes_screen_init()
Cutscene_list.clear();
int u = 0;
for (SCP_vector<cutscene_info>::iterator cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut, u++)
for (auto cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut, ++u)
{
if ((*cut).viewable)
if (cut->flags[Cutscene::Cutscene_Flags::Viewable, Cutscene::Cutscene_Flags::Always_viewable] && !cut->flags[Cutscene::Cutscene_Flags::Never_viewable])
{
Cutscene_list.push_back(u);
}
+14 -9
View File
@@ -10,26 +10,31 @@
#ifndef _FREESPACE_CUTSCENES_SCREEN_HEADER_FILE
#define _FREESPACE_CUTSCENES_SCREEN_HEADER_FILE
#include "globalincs/flagset.h"
#include "globalincs/globals.h"
#include "globalincs/pstypes.h"
namespace Cutscene
{
FLAG_LIST(Cutscene_Flags)
{
Viewable = 0,
Always_viewable,
Never_viewable,
NUM_VALUES
};
}
typedef struct cutscene_info
{
char filename[MAX_FILENAME_LEN];
char name[NAME_LENGTH];
char* description;
bool viewable;
flagset<Cutscene::Cutscene_Flags> flags;
} cutscene_info;
#if SCP_COMPILER_IS_GNU
#pragma GCC diagnostic push
// This suppresses a GCC bug where it thinks that the Cutscenes from the enum class below shadows a global variable
#pragma GCC diagnostic ignored "-Wshadow"
#endif
extern SCP_vector<cutscene_info> Cutscenes;
#if SCP_COMPILER_IS_GNU
#pragma GCC diagnostic pop
#endif
// initializa table data
void cutscene_init();
+7 -1
View File
@@ -55,6 +55,9 @@ int resample_convert(SwrContext* ctx, uint8_t** output,
#ifdef WITH_LIBAV
return avresample_convert(ctx, output, out_plane_size, out_samples, input, in_plane_size, in_samples);
#else
(void)out_plane_size;
(void)in_plane_size;
return swr_convert(ctx, output, out_samples, (const uint8_t**) input, in_samples);
#endif
}
@@ -123,7 +126,7 @@ void AudioDecoder::handleDecodedFrame(AVFrame* frame) {
auto ret = av_samples_alloc(m_outData, &m_outLinesize, OUT_NUM_CHANNELS, m_outNumSamples,
OUT_SAMPLE_FORMAT, 1);
if (ret < 0) {
mprintf(("FFMPEG: Failed to allocate samples!!!"));
mprintf(("FFMPEG: Failed to allocate samples!!!\n"));
return;
}
@@ -220,5 +223,8 @@ void AudioDecoder::finishDecoding() {
// Push the last bits of audio data into the queue
flushAudioBuffer();
}
void AudioDecoder::flushBuffers() {
avcodec_flush_buffers(m_status->audioCodecCtx);
}
}
}
+2
View File
@@ -30,6 +30,8 @@ class AudioDecoder: public FFMPEGStreamDecoder<AudioFrame> {
void decodePacket(AVPacket* packet) override;
void finishDecoding() override;
void flushBuffers() override;
};
}
}
+370 -143
View File
@@ -11,6 +11,7 @@
#include "cutscene/ffmpeg/VideoDecoder.h"
#include "cutscene/ffmpeg/SubtitleDecoder.h"
#include "FFMPEGDecoder.h"
#include "localization/localize.h"
using namespace libs::ffmpeg;
@@ -27,20 +28,26 @@ class AVPacketScope
: _packet(av_packet) {
}
AVPacketScope(const AVPacketScope&) = delete;
AVPacketScope& operator=(const AVPacketScope&) = delete;
~AVPacketScope() {
av_packet_unref(_packet);
}
};
const char* CHECKED_EXTENSIONS[] = {
"webm",
"mp4",
"ogg",
"mve"
};
const char* CHECKED_EXTENSIONS[] = {"webm", "mp4", "ogg",
"png", // This is designed to be used with APNG animations
"mve"};
const char* CHECKED_SUBT_EXTENSIONS[] = {"srt"};
double getFrameRate(AVStream* stream, AVCodecContext* codecCtx) {
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(58, 3, 102)
auto fps = av_q2d(stream->r_frame_rate);
#else
auto fps = av_q2d(av_stream_get_r_frame_rate(stream));
#endif
if (fps < 0.000001)
{
@@ -58,45 +65,111 @@ double getFrameRate(AVStream* stream, AVCodecContext* codecCtx) {
CodecContextParameters getCodecParameters(AVStream* stream) {
CodecContextParameters paras;
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(57, 24, 255)
paras.width = stream->codecpar->width;
paras.height = stream->codecpar->height;
paras.width = stream->codecpar->width;
paras.height = stream->codecpar->height;
paras.pixel_format = (AVPixelFormat)stream->codecpar->format;
paras.channel_layout = stream->codecpar->channel_layout;
paras.sample_rate = stream->codecpar->sample_rate;
paras.audio_format = (AVSampleFormat)stream->codecpar->format;
paras.sample_rate = stream->codecpar->sample_rate;
paras.audio_format = (AVSampleFormat)stream->codecpar->format;
paras.codec_id = stream->codecpar->codec_id;
paras.codec_id = stream->codecpar->codec_id;
#else
paras.width = stream->codec->width;
paras.height = stream->codec->height;
paras.width = stream->codec->width;
paras.height = stream->codec->height;
paras.pixel_format = stream->codec->pix_fmt;
paras.channel_layout = stream->codec->channel_layout;
paras.sample_rate = stream->codec->sample_rate;
paras.audio_format = stream->codec->sample_fmt;
paras.sample_rate = stream->codec->sample_rate;
paras.audio_format = stream->codec->sample_fmt;
paras.codec_id = stream->codec->codec_id;
paras.codec_id = stream->codec->codec_id;
#endif
return paras;
return paras;
}
SCP_string normalizeLanguage(const char* langauge_name) {
if (!stricmp(langauge_name, "eng")) {
return "English";
}
if (!stricmp(langauge_name, "ger")) {
return "German";
}
if (!stricmp(langauge_name, "spa")) {
return "Spanish";
}
if (!stricmp(langauge_name, "eng")) {
return "English";
}
if (!stricmp(langauge_name, "ger")) {
return "German";
}
if (!stricmp(langauge_name, "spa")) {
return "Spanish";
}
// Print to log so that we can find the actual value more easily later
mprintf(("FFmpeg log: Found unknown language value '%s'!\n", langauge_name));
// Print to log so that we can find the actual value more easily later
mprintf(("FFmpeg log: Found unknown language value '%s'!\n", langauge_name));
// Default to english for everything else
return "English";
// Default to english for everything else
return "English";
}
/**
* @brief Given a FFmpeg pixel format returns the format it should be converted to
* @param in_fmt The input format
* @return The output format
*/
AVPixelFormat getConversionFormat(AVPixelFormat in_fmt)
{
switch (in_fmt) {
case AV_PIX_FMT_RGB24:
case AV_PIX_FMT_BGR24:
case AV_PIX_FMT_BGR8:
case AV_PIX_FMT_BGR4:
case AV_PIX_FMT_BGR4_BYTE:
case AV_PIX_FMT_RGB8:
case AV_PIX_FMT_RGB4:
case AV_PIX_FMT_RGB4_BYTE:
case AV_PIX_FMT_RGB48BE:
case AV_PIX_FMT_RGB48LE:
case AV_PIX_FMT_RGB565BE:
case AV_PIX_FMT_RGB565LE:
case AV_PIX_FMT_RGB555BE:
case AV_PIX_FMT_RGB555LE:
case AV_PIX_FMT_BGR565BE:
case AV_PIX_FMT_BGR565LE:
case AV_PIX_FMT_BGR555BE:
case AV_PIX_FMT_BGR555LE:
case AV_PIX_FMT_RGB444LE:
case AV_PIX_FMT_RGB444BE:
case AV_PIX_FMT_BGR444LE:
case AV_PIX_FMT_BGR444BE:
case AV_PIX_FMT_BGR48BE:
case AV_PIX_FMT_BGR48LE:
case AV_PIX_FMT_0RGB:
case AV_PIX_FMT_RGB0:
case AV_PIX_FMT_0BGR:
case AV_PIX_FMT_BGR0:
return AV_PIX_FMT_BGR24;
case AV_PIX_FMT_RGBA64BE:
case AV_PIX_FMT_RGBA64LE:
case AV_PIX_FMT_BGRA64BE:
case AV_PIX_FMT_BGRA64LE:
case AV_PIX_FMT_ARGB:
case AV_PIX_FMT_RGBA:
case AV_PIX_FMT_ABGR:
case AV_PIX_FMT_BGRA:
return AV_PIX_FMT_BGRA;
default:
// Assume that everything else is converted to YUV 420
return AV_PIX_FMT_YUV420P;
}
}
FramePixelFormat getPixelFormat(AVPixelFormat fmt)
{
switch (fmt) {
case AV_PIX_FMT_BGR24:
return FramePixelFormat::BGR;
case AV_PIX_FMT_BGRA:
return FramePixelFormat::BGRA;
default:
return FramePixelFormat::YUV420;
}
}
}
@@ -143,7 +216,15 @@ std::unique_ptr<InputStream> openStream(const SCP_string& name) {
return input;
}
std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream>& stream) {
std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream>& stream,
std::unique_ptr<InputStream>& subt,
const PlaybackProperties& properties)
{
if (subt && properties.looping) {
mprintf(("FFmpeg: External subtitles and looping movies are not supported!\n"));
return nullptr;
}
std::unique_ptr<DecoderStatus> status(new DecoderStatus());
auto ctx = stream->m_ctx->ctx();
@@ -161,14 +242,18 @@ std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream>& st
return nullptr;
}
auto audioStream = av_find_best_stream(ctx, AVMEDIA_TYPE_AUDIO, -1, videoStream, &status->audioCodec, 0);
if (audioStream < 0) {
if (audioStream == AVERROR_STREAM_NOT_FOUND) {
mprintf(("FFmpeg: No audio stream found in file!\n"));
} else if (videoStream == AVERROR_DECODER_NOT_FOUND) {
mprintf(("FFmpeg: Codec for audio stream could not be found!\n"));
} else {
mprintf(("FFmpeg: Unknown error while finding audio stream!\n"));
int audioStream = -1;
if (properties.with_audio) {
audioStream = av_find_best_stream(ctx, AVMEDIA_TYPE_AUDIO, -1, videoStream, &status->audioCodec, 0);
if (audioStream < 0) {
if (audioStream == AVERROR_STREAM_NOT_FOUND) {
mprintf(("FFmpeg: No audio stream found in file!\n"));
} else if (audioStream == AVERROR_DECODER_NOT_FOUND) {
mprintf(("FFmpeg: Codec for audio stream could not be found!\n"));
} else {
mprintf(("FFmpeg: Unknown error while finding audio stream!\n"));
}
}
}
@@ -180,33 +265,60 @@ std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream>& st
status->audioStream = ctx->streams[audioStream];
}
auto& current_language = Lcl_languages[Lcl_current_lang];
for (uint32_t i = 0; i < ctx->nb_streams; ++i) {
auto test_stream = ctx->streams[i];
if (subt) {
auto subtCtx = subt->m_ctx->ctx();
auto subtStream = av_find_best_stream(subtCtx, AVMEDIA_TYPE_SUBTITLE, -1, -1, nullptr, 0);
if (subtStream < 0) {
if (subtStream == AVERROR_STREAM_NOT_FOUND) {
mprintf(("FFmpeg: No subtitle stream found in subtitle file!\n"));
} else if (subtStream == AVERROR_DECODER_NOT_FOUND) {
mprintf(("FFmpeg: Codec for subtitle stream could not be found!\n"));
} else {
mprintf(("FFmpeg: Unknown error while finding subtitle stream!\n"));
}
} else {
status->subtitleStream = subtCtx->streams[subtStream];
status->externalSubtitles = true;
status->subtitleStreamIndex = subtStream;
}
}
if (status->subtitleStream == nullptr) {
// We don't have an external subtitle stream or loading from that file has failed
auto& current_language = Lcl_languages[Lcl_current_lang == LCL_UNTRANSLATED ? LCL_DEFAULT : Lcl_current_lang];
for (uint32_t i = 0; i < ctx->nb_streams; ++i) {
auto test_stream = ctx->streams[i];
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(57, 24, 255)
auto& pars = test_stream->codecpar;
auto& pars = test_stream->codecpar;
if (!(pars->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
continue;
}
if (!(pars->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
continue;
}
#endif
AVDictionaryEntry* tag = nullptr;
if ((tag = av_dict_get(test_stream->metadata, "language", nullptr, 0)) == nullptr) {
continue;
}
AVDictionaryEntry* tag = nullptr;
if ((tag = av_dict_get(test_stream->metadata, "language", nullptr, 0)) == nullptr) {
continue;
}
auto normalized_language = normalizeLanguage(tag->value);
auto normalized_language = normalizeLanguage(tag->value);
if (!stricmp(normalized_language.c_str(), current_language.lang_name)) {
status->subtitleStreamIndex = i;
status->subtitleStream = test_stream;
break;
if (!stricmp(normalized_language.c_str(), current_language.lang_name)) {
status->subtitleStreamIndex = i;
status->subtitleStream = test_stream;
break;
}
}
}
status->videoCodecPars = getCodecParameters(status->videoStream);
if (properties.looping && status->videoCodecPars.codec_id == AV_CODEC_ID_INTERPLAY_VIDEO) {
mprintf(("FFmpeg: Looping is not supported for inteplay (MVE) movies!\n"));
return nullptr;
}
int err;
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(57, 24, 255)
status->videoCodecCtx = avcodec_alloc_context3(status->videoCodec);
@@ -263,36 +375,37 @@ std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream>& st
status->audioCodec->name ? status->audioCodec->name : "<Unknown>"));
}
if (status->subtitleStreamIndex >= 0) {
// Not really sure if this makes sense for subtitles but it shouldn't break anything...
status->subtitleCodecPars = getCodecParameters(status->subtitleStream);
if (status->subtitleStream != nullptr) {
// Not really sure if this makes sense for subtitles but it shouldn't break anything...
status->subtitleCodecPars = getCodecParameters(status->subtitleStream);
status->subtitleCodec = avcodec_find_decoder(status->subtitleCodecPars.codec_id);
status->subtitleCodec = avcodec_find_decoder(status->subtitleCodecPars.codec_id);
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(57, 24, 255)
status->subtitleCodecCtx = avcodec_alloc_context3(status->subtitleCodec);
status->subtitleCodecCtx = avcodec_alloc_context3(status->subtitleCodec);
err = avcodec_parameters_to_context(status->subtitleCodecCtx, status->subtitleStream->codecpar);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to copy context parameters! Error: %s\n", errorStr));
return nullptr;
}
err = avcodec_parameters_to_context(status->subtitleCodecCtx, status->subtitleStream->codecpar);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to copy context parameters! Error: %s\n", errorStr));
return nullptr;
}
#else
status->subtitleCodecCtx = status->subtitleStream->codec;
status->subtitleCodecCtx = status->subtitleStream->codec;
#endif
err = avcodec_open2(status->subtitleCodecCtx, status->subtitleCodec, nullptr);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to open subtitle codec! Error: %s\n", errorStr));
}
err = avcodec_open2(status->subtitleCodecCtx, status->subtitleCodec, nullptr);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to open subtitle codec! Error: %s\n", errorStr));
}
mprintf(("FFmpeg: Using subtitle codec %s (%s).\n", status->subtitleCodec->long_name ? status->subtitleCodec->long_name : "<Unknown>",
status->subtitleCodec->name ? status->subtitleCodec->name : "<Unknown>"));
}
mprintf(("FFmpeg: Using subtitle codec %s (%s).\n",
status->subtitleCodec->long_name ? status->subtitleCodec->long_name : "<Unknown>",
status->subtitleCodec->name ? status->subtitleCodec->name : "<Unknown>"));
}
return status;
}
@@ -312,12 +425,35 @@ std::unique_ptr<InputStream> openInputStream(const SCP_string& name) {
return nullptr;
}
std::unique_ptr<InputStream> openSubtitleStream(const SCP_string& name)
{
auto& current_language = Lcl_languages[Lcl_current_lang == LCL_UNTRANSLATED ? LCL_DEFAULT : Lcl_current_lang];
for (auto ext : CHECKED_SUBT_EXTENSIONS) {
SCP_string fileName;
if (strlen(current_language.lang_ext) == 0) {
fileName = name + "." + ext;
} else {
fileName = name + "-" + current_language.lang_ext + "." + ext;
}
auto input = openStream(fileName);
if (input) {
return input;
}
}
return nullptr;
}
}
bool FFMPEGDecoder::initialize(const SCP_string& fileName) {
bool FFMPEGDecoder::initialize(const SCP_string& fileName, const PlaybackProperties& properties)
{
SCP_string movieName = fileName;
// First make the file name lower case
std::transform(movieName.begin(), movieName.end(), movieName.begin(), ::tolower);
std::transform(movieName.begin(), movieName.end(), movieName.begin(), [](char c) { return (char)::tolower(c); });
// Then remove the extension
size_t dotPos = movieName.find('.');
@@ -331,8 +467,10 @@ bool FFMPEGDecoder::initialize(const SCP_string& fileName) {
return false;
}
auto subt = openSubtitleStream(movieName);
// We now have a valid input stream, try to find the correct streams
auto status = initializeStatus(input);
auto status = initializeStatus(input, subt, properties);
if (!status) {
return false;
}
@@ -342,46 +480,178 @@ bool FFMPEGDecoder::initialize(const SCP_string& fileName) {
// We're done, now just put the pointer into this
std::swap(m_input, input);
std::swap(m_subtitleInput, subt);
std::swap(m_status, status);
m_properties = properties;
return true;
}
MovieProperties FFMPEGDecoder::getProperties() {
MovieProperties FFMPEGDecoder::getProperties() const
{
MovieProperties props;
props.size.width = static_cast<size_t>(m_status->videoCodecPars.width);
props.size.height = static_cast<size_t>(m_status->videoCodecPars.height);
props.fps = static_cast<float>(getFrameRate(m_status->videoStream, m_status->videoCodecCtx));
props.pixelFormat = getPixelFormat(getConversionFormat(m_status->videoCodecPars.pixel_format));
return props;
}
void FFMPEGDecoder::startDecoding() {
std::unique_ptr<VideoDecoder> videoDecoder(new VideoDecoder(m_status.get()));
std::unique_ptr<VideoDecoder> videoDecoder(new VideoDecoder(m_status.get(), getConversionFormat(m_status->videoCodecPars.pixel_format)));
std::unique_ptr<AudioDecoder> audioDecoder;
std::unique_ptr<SubtitleDecoder> subtitleDecoder;
std::unique_ptr<SubtitleDecoder> subtitleDecoder;
if (hasAudio()) {
audioDecoder.reset(new AudioDecoder(m_status.get()));
}
if (hasSubtitles()) {
subtitleDecoder.reset(new SubtitleDecoder(m_status.get()));
}
if (hasSubtitles()) {
subtitleDecoder.reset(new SubtitleDecoder(m_status.get()));
}
std::unique_ptr<std::thread> subtitle_thread;
if (hasExternalSubtitle()) {
// Start a new thread for the subtitles since otherwise we would need to make sure that neither of the input
// streames starves while the other waits for more space in the queues
subtitle_thread.reset(
new std::thread([this, &subtitleDecoder]() { runSubtitleDecoder(subtitleDecoder.get()); }));
}
auto ctx = m_input->m_ctx->ctx();
AVPacket packet;
do {
if (m_properties.looping) {
// Only seek if we are looping the movie. The MVE code doesn't support seeking to this function may not be
// called there
auto seek_err = av_seek_frame(ctx, -1, 0, AVSEEK_FLAG_BACKWARD);
if (seek_err < 0) {
char errorStr[512];
av_strerror(seek_err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to seek to start of movie file! Error: %s\n", errorStr));
break;
}
}
videoDecoder->flushBuffers();
if (audioDecoder) {
audioDecoder->flushBuffers();
}
if (subtitleDecoder) {
subtitleDecoder->flushBuffers();
}
while (isDecoding()) {
auto read_err = av_read_frame(ctx, &packet);
AVPacketScope scope(&packet);
if (read_err < 0) {
if (read_err == AVERROR_EOF) {
// Finished reading -> break out of loop
break;
} else if (avio_feof(ctx->pb) != 0) {
// Also EOF!
break;
} else {
// Some kind of other error, try to continue reading
char errorStr[512];
av_strerror(read_err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to read frame! Error: %s\n", errorStr));
// Skip packet
continue;
}
}
if (packet.stream_index == m_status->videoStreamIndex) {
videoDecoder->decodePacket(&packet);
VideoFramePtr ptr;
while ((ptr = videoDecoder->getFrame()) != nullptr) {
pushFrameData(std::move(ptr));
}
} else if (audioDecoder && packet.stream_index == m_status->audioStreamIndex) {
audioDecoder->decodePacket(&packet);
AudioFramePtr ptr;
while ((ptr = audioDecoder->getFrame()) != nullptr) {
pushAudioData(std::move(ptr));
}
} else if (subtitleDecoder && packet.stream_index == m_status->subtitleStreamIndex) {
subtitleDecoder->decodePacket(&packet);
SubtitleFramePtr ptr;
while ((ptr = subtitleDecoder->getFrame()) != nullptr) {
pushSubtitleData(std::move(ptr));
}
}
}
if (isDecoding()) {
// If we are still alive then read the last frames from the decoders
videoDecoder->finishDecoding();
VideoFramePtr video_ptr;
while ((video_ptr = videoDecoder->getFrame()) != nullptr) {
pushFrameData(std::move(video_ptr));
}
if (audioDecoder) {
audioDecoder->finishDecoding();
AudioFramePtr audio_frame;
while ((audio_frame = audioDecoder->getFrame()) != nullptr) {
pushAudioData(std::move(audio_frame));
}
}
}
// If the video is being looped then we start again from the beginning
} while (m_properties.looping && isDecoding());
// Stop the decoder first to let the subtitle thread know that it shouldn't continue
stopDecoder();
if (subtitle_thread) {
subtitle_thread->join();
}
}
bool FFMPEGDecoder::hasAudio() const { return m_status->audioStreamIndex >= 0; }
bool FFMPEGDecoder::hasSubtitles() const { return m_status->subtitleStream != nullptr; }
bool FFMPEGDecoder::hasExternalSubtitle() const { return m_status->externalSubtitles; }
void FFMPEGDecoder::close() {
if (m_status) {
m_status = nullptr;
}
if (m_input) {
// This will delete the InputStream pointer and free all data
m_input = nullptr;
}
if (m_subtitleInput) {
m_subtitleInput = nullptr;
}
}
void FFMPEGDecoder::runSubtitleDecoder(SubtitleDecoder* decoder)
{
auto ctx = m_subtitleInput->m_ctx->ctx();
AVPacket packet;
while (isDecoding()) {
auto read_err = av_read_frame(ctx, &packet);
AVPacketScope scope(&packet);
if (avio_feof(ctx->pb) != 0) {
// EOF!!
break;
} else if (read_err < 0) {
if (read_err < 0) {
if (read_err == AVERROR_EOF) {
// Finished reading -> break out of loop
break;
} else if (avio_feof(ctx->pb) != 0) {
// Also EOF!
break;
} else {
// Some kind of other error, try to continue reading
char errorStr[512];
@@ -393,67 +663,24 @@ void FFMPEGDecoder::startDecoding() {
}
}
if (packet.stream_index == m_status->videoStreamIndex) {
videoDecoder->decodePacket(&packet);
if (packet.stream_index == m_status->subtitleStreamIndex) {
decoder->decodePacket(&packet);
VideoFramePtr ptr;
while((ptr = videoDecoder->getFrame()) != nullptr) {
pushFrameData(std::move(ptr));
SubtitleFramePtr ptr;
while ((ptr = decoder->getFrame()) != nullptr) {
pushSubtitleData(std::move(ptr));
}
} else if (audioDecoder && packet.stream_index == m_status->audioStreamIndex) {
audioDecoder->decodePacket(&packet);
AudioFramePtr ptr;
while ((ptr = audioDecoder->getFrame()) != nullptr) {
pushAudioData(std::move(ptr));
}
} else if (subtitleDecoder && packet.stream_index == m_status->subtitleStreamIndex) {
subtitleDecoder->decodePacket(&packet);
SubtitleFramePtr ptr;
while((ptr = subtitleDecoder->getFrame()) != nullptr) {
pushSubtitleData(std::move(ptr));
}
}
}
}
if (isDecoding()) {
// If we are still alive then read the last frames from the decoders
videoDecoder->finishDecoding();
VideoFramePtr video_ptr;
while ((video_ptr = videoDecoder->getFrame()) != nullptr) {
pushFrameData(std::move(video_ptr));
}
decoder->finishDecoding();
if (audioDecoder) {
audioDecoder->finishDecoding();
AudioFramePtr audio_frame;
while ((audio_frame = audioDecoder->getFrame()) != nullptr) {
pushAudioData(std::move(audio_frame));
}
SubtitleFramePtr ptr;
while ((ptr = decoder->getFrame()) != nullptr) {
pushSubtitleData(std::move(ptr));
}
}
stopDecoder();
}
bool FFMPEGDecoder::hasAudio() {
return m_status->audioStreamIndex >= 0;
}
bool FFMPEGDecoder::hasSubtitles() {
return m_status->subtitleStreamIndex >= 0;
}
void FFMPEGDecoder::close() {
if (m_status) {
m_status = nullptr;
}
if (m_input) {
// This will delete the InputStream pointer and free all data
m_input = nullptr;
}
}
}
}
+15 -5
View File
@@ -8,26 +8,36 @@ struct InputStream;
struct DecoderStatus;
class SubtitleDecoder;
class FFMPEGDecoder: public Decoder {
private:
std::unique_ptr<InputStream> m_input;
std::unique_ptr<InputStream> m_subtitleInput;
std::unique_ptr<DecoderStatus> m_status;
public:
PlaybackProperties m_properties;
bool hasExternalSubtitle() const;
void runSubtitleDecoder(SubtitleDecoder* decoder);
public:
FFMPEGDecoder();
~FFMPEGDecoder() override;
bool initialize(const SCP_string& fileName) override;
bool initialize(const SCP_string& fileName, const PlaybackProperties& properties) override;
MovieProperties getProperties() override;
MovieProperties getProperties() const override;
void startDecoding() override;
bool hasAudio() override;
bool hasAudio() const override;
bool hasSubtitles() override;
bool hasSubtitles() const override;
void close() override;
};
+21
View File
@@ -31,7 +31,25 @@ void SubtitleDecoder::decodePacket(AVPacket* packet) {
}
}
void SubtitleDecoder::finishDecoding() {
// Handle those decoders that have a delay
AVPacket nullPacket;
memset(&nullPacket, 0, sizeof(nullPacket));
nullPacket.data = nullptr;
nullPacket.size = 0;
AVSubtitle subtitle;
while (true) {
int finishedFrame = 1;
auto err = avcodec_decode_subtitle2(m_status->subtitleCodecCtx, &subtitle, &finishedFrame, &nullPacket);
if (err < 0 || !finishedFrame) {
break;
}
pushSubtitleFrame(&nullPacket, &subtitle);
avsubtitle_free(&subtitle);
}
}
void SubtitleDecoder::pushSubtitleFrame(AVPacket* packet, AVSubtitle* subtitle) {
if (subtitle->format != 1) {
@@ -111,6 +129,9 @@ void SubtitleDecoder::pushSubtitleFrame(AVPacket* packet, AVSubtitle* subtitle)
pushFrame(std::move(frame));
}
void SubtitleDecoder::flushBuffers() {
avcodec_flush_buffers(m_status->subtitleCodecCtx);
}
}
}
+1
View File
@@ -16,6 +16,7 @@ class SubtitleDecoder: public FFMPEGStreamDecoder<SubtitleFrame> {
void finishDecoding() override;
void pushSubtitleFrame(AVPacket* subtitle, AVSubtitle* pSubtitle);
void flushBuffers() override;
};
}
+61 -62
View File
@@ -3,11 +3,9 @@
#include "tracing/tracing.h"
namespace {
const AVPixelFormat DESTINATION_FORMAT = AV_PIX_FMT_YUV420P;
SwsContext* getSWSContext(int width, int height, AVPixelFormat fmt) {
return sws_getContext(width, height, fmt, width, height, DESTINATION_FORMAT,
SWS_BILINEAR, nullptr, nullptr, nullptr);
SwsContext* getSWSContext(int width, int height, AVPixelFormat fmt, AVPixelFormat destination_fmt)
{
return sws_getContext(width, height, fmt, width, height, destination_fmt, SWS_BILINEAR, nullptr, nullptr, nullptr);
}
double getFrameTime(int64_t pts, AVRational time_base) {
@@ -18,34 +16,53 @@ double getFrameTime(int64_t pts, AVRational time_base) {
namespace cutscene {
namespace ffmpeg {
class FFMPEGVideoFrame: public VideoFrame {
public:
FFMPEGVideoFrame() : frame(nullptr) {
}
size_t _width;
size_t _height;
AVFrame* _frame;
public:
FFMPEGVideoFrame(size_t width, size_t height, AVFrame* frame) : _width(width), _height(height), _frame(frame) {}
~FFMPEGVideoFrame() override {
if (frame != nullptr) {
av_freep(&frame->data[0]);
av_frame_free(&frame);
if (_frame != nullptr) {
av_freep(&_frame->data[0]);
av_frame_free(&_frame);
}
}
DataPointers getDataPointers() override {
DataPointers ptrs;
ptrs.y = frame->data[0];
ptrs.u = frame->data[1];
ptrs.v = frame->data[2];
return ptrs;
size_t getPlaneNumber() override
{
switch (_frame->format) {
case AV_PIX_FMT_YUV420P:
// YUV data is planar
return 3;
default:
// Everything else is packed
return 1;
}
}
FrameSize getPlaneSize(size_t plane) override
{
switch (_frame->format) {
case AV_PIX_FMT_YUV420P: {
// YUV data is planar
auto width = plane > 0 ? _width / 2 : _width;
auto height = plane > 0 ? _height / 2 : _height;
AVFrame* frame;
return {width, height, (size_t)_frame->linesize[plane]};
}
default:
// Everything else is packed
return {_width, _height, (size_t)_frame->linesize[plane]};
}
}
void* getPlaneData(size_t plane) override { return _frame->data[plane]; }
};
VideoDecoder::VideoDecoder(DecoderStatus* status)
: FFMPEGStreamDecoder(status),
m_frameId(0) {
VideoDecoder::VideoDecoder(DecoderStatus* status, AVPixelFormat destination_fmt)
: FFMPEGStreamDecoder(status), m_frameId(0), m_destinationFormat(destination_fmt)
{
m_swsCtx = getSWSContext(m_status->videoCodecPars.width, m_status->videoCodecPars.height,
m_status->videoCodecPars.pixel_format);
m_status->videoCodecPars.pixel_format, destination_fmt);
}
VideoDecoder::~VideoDecoder() {
@@ -53,53 +70,32 @@ VideoDecoder::~VideoDecoder() {
}
void VideoDecoder::convertAndPushPicture(const AVFrame* frame) {
// Allocate a picture to hold the YUV data
// Allocate a picture to hold the destination data
AVFrame* yuvFrame = av_frame_alloc();
av_frame_copy(yuvFrame, frame);
yuvFrame->format = DESTINATION_FORMAT;
yuvFrame->format = m_destinationFormat;
av_image_alloc(yuvFrame->data,
yuvFrame->linesize,
m_status->videoCodecPars.width,
m_status->videoCodecPars.height,
DESTINATION_FORMAT,
1);
av_image_alloc(yuvFrame->data, yuvFrame->linesize, m_status->videoCodecPars.width, m_status->videoCodecPars.height,
m_destinationFormat, 1);
std::unique_ptr<FFMPEGVideoFrame> videoFramePtr(new FFMPEGVideoFrame());
if (m_status->videoCodecPars.pixel_format == DESTINATION_FORMAT) {
av_image_copy(yuvFrame->data,
yuvFrame->linesize,
(const uint8_t**) (frame->data),
frame->linesize,
DESTINATION_FORMAT,
m_status->videoCodecPars.width,
m_status->videoCodecPars.height);
if (m_status->videoCodecPars.pixel_format == m_destinationFormat) {
av_image_copy(yuvFrame->data, yuvFrame->linesize, (const uint8_t**)(frame->data), frame->linesize,
m_destinationFormat, m_status->videoCodecPars.width, m_status->videoCodecPars.height);
} else {
// Convert frame to YUV
sws_scale(
m_swsCtx,
(uint8_t const* const*) frame->data,
frame->linesize,
0,
m_status->videoCodecPars.height,
yuvFrame->data,
yuvFrame->linesize
);
// Convert frame to destination format
sws_scale(m_swsCtx, (uint8_t const* const*)frame->data, frame->linesize, 0, m_status->videoCodecPars.height,
yuvFrame->data, yuvFrame->linesize);
}
std::unique_ptr<FFMPEGVideoFrame> videoFramePtr(
new FFMPEGVideoFrame(static_cast<size_t>(m_status->videoCodecPars.width),
static_cast<size_t>(m_status->videoCodecPars.height), yuvFrame));
videoFramePtr->id = ++m_frameId;
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(58, 3, 102)
videoFramePtr->frameTime = getFrameTime(frame->best_effort_timestamp, m_status->videoStream->time_base);
#else
videoFramePtr->frameTime = getFrameTime(av_frame_get_best_effort_timestamp(frame), m_status->videoStream->time_base);
videoFramePtr->frame = yuvFrame;
videoFramePtr->ySize.height = static_cast<size_t>(m_status->videoCodecPars.height);
videoFramePtr->ySize.width = static_cast<size_t>(m_status->videoCodecPars.width);
videoFramePtr->ySize.stride = static_cast<size_t>(yuvFrame->linesize[0]);
// 420P means that the UV channels have half the width and height
videoFramePtr->uvSize.height = static_cast<size_t>(m_status->videoCodecPars.height / 2);
videoFramePtr->uvSize.width = static_cast<size_t>(m_status->videoCodecPars.width / 2);
videoFramePtr->uvSize.stride = static_cast<size_t>(yuvFrame->linesize[1]);
#endif
pushFrame(VideoFramePtr(videoFramePtr.release()));
}
@@ -162,5 +158,8 @@ void VideoDecoder::finishDecoding() {
}
#endif
}
void VideoDecoder::flushBuffers() {
avcodec_flush_buffers(m_status->videoCodecCtx);
}
}
}
+4 -1
View File
@@ -9,17 +9,20 @@ class VideoDecoder: public FFMPEGStreamDecoder<VideoFrame> {
private:
int m_frameId;
SwsContext* m_swsCtx;
AVPixelFormat m_destinationFormat;
void convertAndPushPicture(const AVFrame* frame);
public:
explicit VideoDecoder(DecoderStatus* status);
explicit VideoDecoder(DecoderStatus* status, AVPixelFormat destination_fmt);
~VideoDecoder() override;
void decodePacket(AVPacket* packet) override;
void finishDecoding() override;
void flushBuffers() override;
};
}
}
+4
View File
@@ -33,6 +33,8 @@ struct DecoderStatus {
AVCodec* audioCodec = nullptr;
AVCodecContext* audioCodecCtx = nullptr;
// Subtitles are a bit different since they max come from a different file
bool externalSubtitles = false;
int subtitleStreamIndex = -1;
AVStream* subtitleStream = nullptr;
CodecContextParameters subtitleCodecPars;
@@ -72,6 +74,8 @@ class FFMPEGStreamDecoder {
virtual void finishDecoding() = 0;
virtual void flushBuffers() = 0;
virtual FramePtr<frame_type> getFrame();
};
Loaded 100 of 1132 files, more files were not shown because too many files have changed in this diff. Show more