Compare commits

...
Author SHA1 Message Date
asarium 1111dcf0a8 Add system for reading flags from stdin
This adds support for reading flags from the standard input stream
instead of from the command line. This allows more complex formats to be
used such as JSON which is implemented in this first version. This can
be used for implementing much more sophisticated ways of expressing
complex data structures such as the mod command line.
2019-06-07 18:31:33 +02:00
Goober5000 a94550ee1a Merge pull request #2049 from plieblang/MapIteratorCleanup
Clean up map::iterator usage
2019-05-25 00:45:46 -04:00
plieblang 3dbe27e772 Clean up map::iterator usage 2019-05-24 13:43:04 -07: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
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
Fabian Woltermann a3d2320f0a Merge pull request #1681 from asarium/build/clang-tidy
Add clang-tidy to Travis CI configuration
2018-04-14 11:48:30 +02:00
asarium 9d352ddc5f Fix .clang-tidy format 2018-04-13 16:26:57 +02:00
MageKing17 299e584284 Merge pull request #1684 from asarium/fix/1683
Set team_glow_enabled uniform to proper value
2018-04-13 07:13:48 -07:00
asarium 4f22b12ec6 Mark all external libraries as system includes 2018-04-13 15:40:11 +02:00
asarium 57985b5f1a Enable misc-new-delete-overloads 2018-04-13 12:10:24 +02:00
asarium 513115ceeb Enable misc-noexcept-move-constructor check 2018-04-13 12:10:24 +02:00
asarium 95acebfce8 Add misc-multiple-statement-macro check 2018-04-13 12:10:24 +02:00
asarium ca5605cfb4 Add misc-move-forwarding-reference check 2018-04-13 12:10:24 +02:00
asarium ea4e5f222d Make .clang-tidy easier to read 2018-04-13 12:10:22 +02:00
asarium 538afc73a2 Keep building on Travis CI until more errors have occured
This will make it easier to find warnings and clang-tidy notifications
since ninja won't stop after the first warning or error was reported.
2018-04-13 12:10:03 +02:00
asarium 16560326e7 Add more clang-tidy checks 2018-04-13 12:10:01 +02:00
asarium 68372b18a2 Enable performance clang-tidy warnings 2018-04-13 12:08:56 +02:00
asarium c6abe74f06 Replace noexcept with compatibility macro 2018-04-13 12:08:07 +02:00
asarium f1c79c2ca7 Fix override warnings produced by clang-tidy 2018-04-13 12:08:06 +02:00
asarium 7944eda1cb Add Clang-tidy support 2018-04-13 11:40:38 +02:00
asarium 1571caa95e Set team_glow_enabled uniform to proper value
This was missed when converting the model uniforms to a uniform buffer
and caused some issues with team colors. This sets that uniform to the
value it had before the uniform buffer changes.

This fixes #1683.
2018-04-13 10:36:32 +02:00
m!m 9f97ea909a Merge pull request #1669 from jg18/qtfred2_/fictionViewerDialog
Add fiction viewer dialog to qtFRED
2018-04-13 09:57:01 +02:00
MageKing17 7469558e97 Merge pull request #1676 from asarium/fix/jsonOutputEfxSupport
Write EFX support information to JSON output
2018-04-12 17:10:38 -07:00
jg18 6747c630af Finish up qtFRED fiction viewer dialog 2018-04-11 21:45:38 -07:00
jg18 d80d8dd08e Use SignalBlockers with fiction viewer dialog 2018-04-09 23:51:19 -07:00
jg18 5ebf806c72 fix CI error about unused variable 2018-04-09 23:51:19 -07:00
jg18 6d2d092cc6 wrapup fiction viewer dialog corrections 2018-04-09 23:51:18 -07:00
jg18 cafee9c66a Add qtFRED notice about multiple fiction viewer stages 2018-04-09 23:51:18 -07:00
jg18 8fc281c7be Fix bugs in qtFRED fiction viewer dialog 2018-04-09 23:51:02 -07:00
jg18 8cae09bfe8 Add fiction viewer dialog to qtFRED (WIP) 2018-04-09 23:43:10 -07:00
jg18 5c5e48847e Add qtFRED keyboard shortcut for fiction viewer dialog 2018-04-09 23:42:47 -07:00
Joshua Glatt ae17e3f4b7 Merge pull request #1679 from asarium/qtfred2_/initSystem
Copy original FRED initialization code
2018-04-09 08:08:27 -07:00
m!m ebfc904e52 Merge pull request #1678 from jg18/qtfred2_/guisGalore
Add GUIs for background, shield system, and voice acting editors to qtFRED
2018-04-09 09:47:24 +02:00
asarium f3a3ed982f Copy original FRED initialization code
This copies the original FRED code for initializing the individual game
systems to qtFRED. This should fix the various issues caused by missing
game system initialization calls.
2018-04-09 09:45:41 +02:00
jg18 fabf05454b Make corrections to background editor UI and add dialog shortcut 2018-04-08 21:12:35 -07:00
m!m d309644e53 Merge pull request #1677 from jg18/qtfred2_/blockUiUpdate
Add SignalBlockers to qtFRED
2018-04-08 10:56:37 +02:00
jg18 63b21893df add stub dialog implementations and more corrections 2018-04-07 23:58:43 -07:00
jg18 81f4c03364 corrections to new GUIs 2018-04-07 23:01:04 -07:00
jg18 3668ce67d5 Add SignalBlockers to qtFRED 2018-04-07 19:52:23 -07:00
asarium 28ddf7d8d2 Write EFX support information to JSON output
The initial JSON flags output lacked this information but it is needed
for proper support by the launcher. This adds a new entry in the JSON
structure without changing anything else so it does not require a new
output version.
2018-04-06 13:48:49 +02:00
jg18 b2d427fb00 Add .ui files for background, shield system, and voice acting editor dialogs 2018-04-01 15:31:46 -07:00
Fabian Woltermann 3a4d5788a8 Merge pull request #1675 from asarium/fix/textureDetail
Fix texture detail errors
2018-04-01 20:34:53 +02:00
asarium 7e3ca7eb46 Fix texture detail errors
When I made the texture array changes I forgot to test the texture
detail feature which caused some visual corruption when using a texture
detail which was less than the maximum. This should fix that.
2018-04-01 13:21:14 +02:00
Fabian Woltermann 95620e5de6 Merge pull request #1671 from asarium/fix/soundSetObjectSounds
Assign minimum and maximum value properly in RandomRange
2018-03-29 15:31:04 +02:00
asarium ae738abcf5 Assign minimum and maximum value properly in RandomRange
The minimum and maximum values were not initialized correctly which
caused code which relied on those values to fail unexpectedly.

This assigns the value properly and adds a documentation note which
clarifies when the values are valid.
2018-03-29 14:25:37 +02:00
Tyler Blount e3c815c194 Merge pull request #1657 from asarium/qtfred2_/sexpContextMenu
Add SEXP tree context menu building
2018-03-19 10:53:16 -06:00
asarium daca57de4c Add replace Variable implementation 2018-03-18 22:56:59 +01:00
asarium 5650199b04 Implement "Add paste" 2018-03-18 19:10:22 +01:00
asarium b1e392be2f Add support for adding typed data 2018-03-18 18:58:10 +01:00
asarium 9f0e21f941 Fix menu enablement status
Also added simple add Data implementations
2018-03-18 18:46:19 +01: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 f740583547 Add add/replace/insert actions 2018-03-18 15:49:01 +01:00
asarium fd92813198 Add Cut/Copy/Paste action handlers 2018-03-18 10:35:28 +01:00
asarium fc87b129ac Add expand all action 2018-03-18 10:27:08 +01:00
asarium d5509411de Add data editing support 2018-03-18 10:27:02 +01:00
asarium a1d7ec7855 Add delete action handler 2018-03-17 17:37:56 +01:00
asarium 7d3bc7fc58 Add support for the start_mission parameter to qtFRED 2018-03-17 17:06:50 +01:00
asarium 6ed82d88a9 Fix minor issues in editor code 2018-03-17 17:04:13 +01:00
m!m 8b49ebf323 Merge pull request #1660 from The-E/feature/ogl_anisotropy
Make the OGL_Anisotropy setting more usable
2018-03-17 10:22:51 +01:00
Goober5000 4bcc85e963 Merge pull request #1661 from asarium/fix/booleanSexpCrash
Fix wrong return value when getting boolean value from Lua
2018-03-16 22:19:30 -04: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
asarium 235391154e Fix wrong return value when getting boolean value from Lua
This is probably a bug from when I changed how those functions worked.
The function is supposed to return if it successfully retreived a value
from the Lua stack but instead of returning true if it was, it returned
the value it just retrieved. This works fine if that value is true but
causes issues if it was false.
2018-03-16 22:32:58 +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 1c5bf39e8d Use GL_max_anisotropy by default 2018-03-16 13:05:21 +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
Fabian Woltermann 0b3ff5e698 Make the anisotropy setting controllable via commandline 2018-03-16 08:14:35 +01:00
asarium 5c0e88dd60 Add actions to context menu 2018-03-15 14:18:35 +01:00
asarium 1498367e48 Add SEXP tree context menu building
This adds displaying the correct context menu for the qtFRED SEXP tree
widget. The actions are not implemented yet.
2018-03-14 11:46:59 +01:00
Fabian Woltermann a8747b7b93 Merge pull request #1656 from asarium/fix/noRuntimeDll
Disable building targets with runtime DLLs as default
2018-03-14 10:12:50 +01:00
asarium dadf58f6b1 Disable building targets with runtime DLLs as default
This caused issues for some users and was an accidental change
introduced by the qtFRED merge.
2018-03-14 09:16:51 +01:00
m!m e9a642673c Merge pull request #1654 from asarium/qtfred2_/sync
Merge qtFRED into the main branch
2018-03-12 10:21:44 +01:00
asarium 42fbc92d73 Don't build qtFRED for deploy builds 2018-03-11 13:45:27 +01:00
m!m 6141fc7f73 Merge pull request #1652 from The-E/fix/1623
Fix for 1623
2018-03-11 09:06:20 +01:00
asarium c1fd6e7026 Call processEvents from game_busy
That will avoid unresponsive application errors when loading a big
mission.
2018-03-11 08:49:34 +01:00
Tyler Blount 9114d94e0c Merge pull request #1650 from asarium/qtfred2_/sexpTree
Add initial support for displaying SEXPs in a tree widget
2018-03-10 16:15:09 -07:00
asarium 235234ea66 Fix some warnings 2018-03-10 18:30:55 +01:00
Fabian Woltermann 512887482a use correct array lookups (how did VS not find these....?) 2018-03-10 18:00:30 +01:00
Fabian Woltermann 04fd9679bd Fix mprintf calls 2018-03-10 14:06:12 +01:00
m!m 07a2f5a155 Merge pull request #1651 from TRBlount/fred/changeHeadaniExt
Make APNG the default file extension for the Event Editors head ani file dialog
2018-03-10 12:55:53 +01:00
Fabian Woltermann 85874105e3 Remove unnecessary early exit 2018-03-10 12:17:17 +01:00
Fabian Woltermann 248b70b780 Replace this assert with a proper exit path + debug log print 2018-03-10 12:11:17 +01:00
Fabian Woltermann f05a50f57b Merge pull request #1638 from The-E/feature/lighting_settings_rework
Reworks the lighting settings according to the discussion in #1634.
2018-03-10 08:57:56 +01:00
Fabian Woltermann a5fc5e322d Merge branch 'feature/lighting_settings_rework' of https://github.com/The-E/fs2open.github.com into feature/lighting_settings_rework 2018-03-10 08:16:46 +01:00
Fabian Woltermann 91c4884fd3 Use the correct index in the popup 2018-03-10 08:15:59 +01:00
Fabian Woltermann eaad5a01a2 Create a popup to notify people that shaders are being recompiled 2018-03-10 08:15:59 +01:00
Fabian Woltermann 905417b866 Use 32 as a default specPower value in the Blinn-Phong render path 2018-03-10 08:15:59 +01:00
asarium 5061a112db Set default shader uniforms every time the shader is compiled 2018-03-10 08:15:59 +01:00
Fabian Woltermann b7981c0ce4 Implemented callback and shader recompile, but there is still strange behaviour 2018-03-10 08:15:59 +01:00
Fabian Woltermann c0328bb4f5 Beams should always be rendered at lighting detail >= 2 2018-03-10 08:15:59 +01:00
Fabian Woltermann dd2074d91d Reworks the lighting settings according to the discussion in #1634.
This fixes #1634
2018-03-10 08:15:59 +01:00
TRBlount e7a8adb367 Make APNG default file for head ani selection 2018-03-09 16:11:57 -07:00
asarium 809ac2300d Turn modified state into a signal 2018-03-09 23:52:21 +01:00
Fabian Woltermann 8ea179781a Merge pull request #1610 from asarium/feature/windowIcon
Allow mods to specify the window icon
2018-03-09 20:06:54 +01:00
Fabian Woltermann 77768b3328 Merge pull request #1632 from asarium/opengl/betterDecals
Add normal map rendering to decals
2018-03-09 20:06:06 +01:00
Fabian Woltermann 873162690d Merge pull request #1649 from asarium/fix/1647
Fix rendering position of hardpoint models
2018-03-09 20:03:31 +01:00
Fabian Woltermann 5c5ce5e66a Use the correct index in the popup 2018-03-09 15:00:39 +01:00
Fabian Woltermann 7d54dd9a05 Create a popup to notify people that shaders are being recompiled 2018-03-09 14:57:40 +01:00
asarium eb322476b2 Add initial tree creation code to event editor
With these changes the event editor can now display the SEXP tree of a
mission. No other operations are supported at the moment.
2018-03-08 22:42:45 +01:00
asarium aadb22c9f1 Fix the rest of the SEXP tree code 2018-03-08 22:28:25 +01:00
asarium d4b0dc9cc2 Convert mask color to proper alpha channels for SEXP icons 2018-03-08 22:28:25 +01:00
asarium b7e703553b Port sexp tree 2018-03-08 22:28:25 +01:00
Tyler Blount 6b97dcfe60 Merge pull request #1648 from asarium/qtfred2_/sync
Sync qtfred branch
2018-03-08 12:05:57 -07:00
asarium 8099bb737b Fix rendering position of hardpoint models
The previous fix to the weapon orientation failed to account for the
change from local to global space for the weapon position. This fixes
that by rotating the model positions to world space before submitting
the render call.

This fixes #1647.
2018-03-08 11:57:34 +01:00
asarium 91d6d90c9b Merge branch 'master' into qtfred2_/sync 2018-03-08 10:34:00 +01:00
m!m e5e5d14108 Merge pull request #1646 from asarium/fix/1645
Avoid reusing model material instance when setting fog
2018-03-06 18:59:12 +01:00
asarium 4fa43ed639 Avoid reusing model material instance when setting fog
The rendering material used by the model render list was reused by
multiple draw call submissions so a non-transparent mesh would reset the
fog value set before which would break meshes submitted after that.

There are still some issues with how the fog is rendered which causes
differences between how opaque and transparent meshes are drawn but I
will fix that in another pull request.

This fixes #1645.
2018-03-06 17:34:29 +01:00
asarium 1ace8b3abc Reenable decals in nebulas
With the recent changes to how fog is handled in nebulas it is now
possible to render decals correctly in a nebula environment so there is
no need to disable decals when the mission is in a nebula.
2018-03-06 11:38:07 +01:00
asarium 520e532c56 Add normal map rendering to decals
This changes the decal system so that it is able to modify the normal
map of the scene. I tested this with some existing normal maps but I am
not entirely sure if the tangent matrix I construct uses the right
values so some additional testing with normal maps made specifically for
decals would be good.

This also fixed the issues introduced by the changes to how directional
lighting was handled. Now a decal can have a diffuse and a glow map. The
diffuse map is used to change the values of the color buffer and also
supports ambient lighting. The glow map renders into the emissive buffer
and should be used for effects that should not receive lighting.
2018-03-06 11:38:01 +01:00
Fabian Woltermann 9a9e088861 Merge pull request #1644 from asarium/opengl/nebulaPostProcessing
Improve handling of nebula fog for deferred lighting
2018-03-06 09:34:43 +01:00
asarium 39f24bce23 Improve handling of nebula fog for deferred lighting
The previous method of rendering nebula fog didn't work correctly with
deferred shading since it changed the color of the material which
obviously caused some issues when it received light from a beam or a
weapon. This wasn't very noticable before because the directional lights
were handled correctly but since all the lighting operations have been
moved into the deferred shading phase it is very obvious that something
is wrong with our nebula rendering.

This fixes that by introducing a new shader which does a fullscreen pass
after resolving all the lights. It applies the usual fog formula based
on the depth of the fragment but it can only use a fixed distance range.
FSO support specifying a range for every object type but the default
range I chose should work properly for all ship types.

The new code only applies to opaque meshes. Transparent meshes are
fogged using the standard formula.
2018-03-05 22:40:05 +01:00
m!m 3dd9bc8aef Merge pull request #1643 from asarium/fix/hudHardpointsStencil
Fix stencil rendering in hardpoint rendering
2018-03-05 17:00:46 +01:00
Fabian Woltermann 03aa479efc Merge pull request #1642 from asarium/fix/hardpointOrientation
Fix missile hardpoint orientation in HUD gauge
2018-03-05 14:37:25 +01:00
asarium 31931777bc Fix stencil rendering in hardpoint rendering
There were actually multiple issues here. The addition of color mask and
stencil state to the material system overwrote the state set by the
hardpoint renderer so the stencil buffer was never written or read
correctly. I fixed this by introducing three new model render flags
(there were a few open slots in the bit mask so I used those) which set
the correct state using the material system. That also makes setting up
the rendering environment much easier.

Second, gr_opengl_stencil_set used mixed up parameter values which were
probably broken when I introduced more detailed stencil state tracking.
I restored those values to how they were in 3.8.

This fixes the other issue reported in #1640.
2018-03-05 14:28:59 +01:00
Fabian Woltermann 59d0c561d6 Use 32 as a default specPower value in the Blinn-Phong render path 2018-03-05 09:06:43 +01:00
Fabian Woltermann ca55f4ea9c Merge pull request #1641 from asarium/fix/lazySoundLoading
Load unloaded sounds when trying to determine sound length
2018-03-05 08:28:24 +01:00
Fabian Woltermann 8c223afcd0 Merge pull request #1639 from asarium/opengl/unifiedGammaHandling
Move gamma correction into common header
2018-03-05 08:27:29 +01:00
Fabian Woltermann 4dc8c57d3c Merge pull request #1 from asarium/fix/shaderDefaultUniforms
Set default shader uniforms every time the shader is compiled
2018-03-05 08:02:51 +01:00
asarium 82f74d570b Fix missile hardpoint orientation in HUD gauge
The code previously used the matrix stack for handling the orientation
or the weapon models. That is no longer supported by the model renderer
(since it would make handling the transforms harder for no real reason).
I fixed the issue by passing the object orientation directory to the
model render function.

This is a fix for one of the problems mentioned in #1640.
2018-03-05 00:20:21 +01:00
asarium 8df4835d51 Set default shader uniforms every time the shader is compiled 2018-03-04 23:30:49 +01:00
asarium 5a5dbd0df2 Load unloaded sounds when trying to determine sound length
This can happen if a script tries to determine the length of a sound
before actually playing it. This fixes the assertion by loading the
sound when it is necessary.
2018-03-04 22:41:15 +01:00
Fabian Woltermann cc876f8bc3 Implemented callback and shader recompile, but there is still strange behaviour 2018-03-04 20:14:09 +01:00
m!m 45d09fd49b Merge pull request #1637 from The-E/feature/no_max_lights
Remove the MAX_LIGHTS define
2018-03-04 16:45:43 +01:00
m!m 6fcdabeb45 Merge pull request #1635 from asarium/fix/emissiveLightNebula
Handle emissive light properly in nebulas
2018-03-04 16:45:14 +01:00
Fabian Woltermann 2e632467f4 Beams should always be rendered at lighting detail >= 2 2018-03-04 16:31:03 +01:00
asarium 5c599fa9ee Move gamma correction into common header
This moves the constant definition and functions for converting from and
to linear color space into a single file that is included in all other
files.
2018-03-04 13:21:45 +01:00
asarium 6b654ce38a Handle emissive light properly in nebulas
The emissive part of the lighting was not using the fog values properly
so ships didn't rendered right in nebulas. This fixes that by applying
the standard fog color transform to the emissive part of the scene.
2018-03-04 12:29:01 +01:00
Fabian Woltermann 2cba774a33 Reworks the lighting settings according to the discussion in #1634.
This fixes #1634
2018-03-04 10:25:45 +01:00
Fabian Woltermann 32fec00e97 Remove the MAX_LIGHTS define 2018-03-04 08:55:21 +01:00
niffiwan 66c9baf893 Merge pull request #1626 from asarium/opengl/vertexInterfaceBlocks
Use vertex interface blocks for vertex shader attributes
2018-03-04 10:52:59 +10:00
niffiwan 1c04be91bb Merge pull request #1624 from asarium/cleanup/grFog
Remove gr_set_fog
2018-03-04 10:52:42 +10:00
m!m 6d52cab0a4 Merge pull request #1627 from asarium/fix/lineDrawList
Add a mechanism for batching line draw calls
2018-03-03 22:46:50 +01:00
Samuel Cho aa60a639fb Merge pull request #1633 from The-E/fix/team_colors_washed_out
Add SRGB adjustment to the team colors
2018-03-03 12:25:27 -08:00
asarium dfd9fe7610 Use vertex interface blocks for vertex shader attributes
This is a minor cleanup of how the engine passes vertex attribute data
from one shader stage to the next. The current code uses standalone
attribute variables which require a unique name over the entire shader
program which means that the variable names need to be different when a
geometry shader is used which makes the code more complicated and harder
to understand.
2018-03-03 19:34:18 +01:00
Fabian Woltermann ef0c6b5c78 this should do it 2018-03-03 16:33:00 +01:00
Fabian Woltermann a3f493d8c1 make the code more readable here 2018-03-03 15:16:40 +01:00
Fabian Woltermann b6981875a5 Address some feedback make it all work correctly 2018-03-03 15:04:46 +01:00
Fabian Woltermann 7c1147541d Add SRGB adjustment to the team colors, make the logic less weird. 2018-03-03 11:48:02 +01:00
Karajorma ef6c5d4da7 Still have some old variable names 2018-03-01 20:09:34 +08:00
niffiwan be9a881cb5 Merge pull request #1630 from niffiwan/bsp_opt
add small bsp tree optimisation
2018-03-01 21:45:58 +10: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
niffiwan 8f2aec3b9a add small bsp tree optimisation
don't add no_collide (& similar) submodels to the bsp trees
this has been in the fotg branch for ages without causing any apparant
issues
2018-03-01 20:00:59 +10:00
MageKing17 78abbf89e6 Merge pull request #1625 from Flip-Sandwich/master
Fixes electronics flag behavior with shockwaves
2018-02-27 19:09:32 -08:00
Fabian Woltermann 4de3451d6c Merge pull request #1628 from The-E/fix/lab-glowpoints
Make glowpoints in the lab work correctly
2018-02-26 12:16:33 +01:00
Fabian Woltermann 8f5f77fa42 Merge pull request #1622 from asarium/opengl/directionalDeferredLights
Use deferred shader for applying directional lights
2018-02-26 11:18:33 +01:00
Fabian Woltermann 354246caf4 Make sure that glowpoints attached to rotating subobjects actually do rotate in the lab 2018-02-26 09:49:13 +01:00
faceman 4797b29311 fixes shockwaves with electronics flagged weapons, properly this time 2018-02-26 15:42:54 +11:00
asarium 2e0253e301 Add a mechanism for batching line draw calls
The previous version used NanoVG which caused quite a serious FPS drop.
This adds a buffer batching class which groups line drawing operations
together and submits them to the GPU with a single draw call.
2018-02-25 19:55:41 +01:00
asarium 0d188fe076 Use deferred shader for applying directional lights
This moves all lighting operations into the deferred shading phase of
the rendering pipeline. Previously, directional lights were applied to
all objects while they were being rendered. This was probably done to
avoid doing multiple full screen passes later but caused some problems
since the color information in the G-buffers was not correct for doing
later lighting operations.

This was especially noticable in dark scenes where point lights would
appear to ignore the color of the rendered objects. This should be fixed
with these changes.

I did some performance testing and to my surprise this actually improves
performance in very demanding scenes. My guess would be that applying
the shadows while rendering the objects caused a lot of overdraw which
is not the case anymore since shadows are only computed for visible
pixels. In simple scenes the opposite happens which leads to decreased
performance in those cases but in my opinion the improvement in
demanding scenes outweights this performance decrease.
2018-02-25 12:43:45 +01:00
asarium c463709399 Remove gr_set_fog
Specifying the fog rendering options is now handled by the materials
system and the implementation of gr_set_fog was pretty much empty so I
removed it.
2018-02-24 19:37:39 +01:00
asarium 25357ce8a2 Allow mods to specify the window icon
This is mostly intended for total conversions to allow them to set
themselves apart from FS2 based mods. It uses the new in-memory
filesystem to support a default icon in case no icon was specified by
the mod.
2018-02-24 18:08:41 +01: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
MageKing17 9953c6a7c4 Merge pull request #1616 from The-E/1615_fix
Do not try to delete opengl buffers when we have no idea what they are
2018-02-23 09:33:20 -08:00
MageKing17 1db36b7ba5 Merge pull request #1619 from The-E/debug_filter_defaults
The extra debug filters really should not be enabled by default.
2018-02-23 09:25:31 -08:00
Fabian Woltermann 77b6648d22 Merge pull request #1613 from asarium/opengl/shaderIncludes
Add support for includes in shader files
2018-02-23 12:58:04 +01:00
Fabian Woltermann 09ca5d3dd6 Merge pull request #1621 from The-E/dockpoint_warning
Print out a warning if we can't find a dockpoint during missionparse
2018-02-21 08:36:35 +01:00
Fabian Woltermann 942f72d09a Print out a warning if we can't find either dockpoint 2018-02-20 16:47:02 +01:00
Fabian Woltermann ee27db60de The extra debug filters really should not be enabled by default. 2018-02-20 11:54:23 +01:00
MageKing17 66c0d27270 Merge pull request #1618 from MageKing17/bugfix/ai-profiles-parsing-end
Make AI profile tables actually stop parsing if #End is missing.
2018-02-18 15:10:44 -08:00
m!m 206364a113 Merge pull request #1617 from The-E/missile_lighting_no_export
Do not export -missile_lighting to launchers
2018-02-18 23:14:05 +01:00
MageKing17 ac9547d610 Make AI profile tables actually stop parsing if #End is missing.
By making parse_ai_profiles_tbl() actually check the return value of skip_to_start_of_string_either() (and break if the appropriate characters aren't found), AI profile tables should no longer keep parsing past the end of the file and into invalid memory, until they either find an "#End" in memory somewhere or just plain crash.

As a pleasant bonus, a missing "#End" should now generate an appropriate error message.
2018-02-18 13:13:18 -08:00
Fabian Woltermann 6534c0a3f6 Remove the -missile_lighting flag from the list of exported cmdline options 2018-02-18 22:12:29 +01:00
Fabian Woltermann cdeeee688d Merge pull request #1605 from Flip-Sandwich/subsysdamagefix
Negative damages no longer heal subsystems
2018-02-18 21:01:57 +01:00
Fabian Woltermann 8b5f257d0d Merge pull request #1614 from asarium/feature/luaLanguageFunctions
Add lua functions for accessing the current engine language
2018-02-18 20:59:23 +01:00
Fabian Woltermann b2652e0628 While working through the atexit table, this function somehow got called, leading to the debug_filter.cfg being altered, as explained in #1615 2018-02-18 19:55:44 +01:00
asarium 2eea0a6eb1 Add lua functions for accessing the current engine language
This can be used by scripts to implement language specific behavior.
2018-02-18 17:12:17 +01:00
m!m 67c67548fd Merge pull request #1611 from The-E/smooth_lab_cam
Make the lab's camera smoother
2018-02-18 16:05:33 +01:00
m!m 12e45e88fa Merge pull request #1612 from The-E/LabHelpText
Print a helpful reminder about the camera controls
2018-02-18 00:01:25 +01:00
Fabian Woltermann e2129355bf Remove the bloom printout, add a camera distance printout 2018-02-17 21:00:47 +01:00
m!m 857582a980 Merge pull request #1608 from The-E/LightTypeEnum
Use an enum class to mark light types
2018-02-17 19:24:51 +01:00
asarium c4dd593dd7 Move lighing functions into one file
There was a slight difference between the GGX function from the main
shader and the deferred shader. The deferred shader didn't use the
fresnel value stored in the G-buffer for some reason.
2018-02-17 19:07:26 +01:00
asarium 30404d4b04 Move shadow functions into separate shader file 2018-02-17 19:02:02 +01:00
asarium c8e3e01ca0 Add support for includes in shader files
This can be used for keeping code for common functionality in one file
(e.g. lighting functions). The code which detects include statements is
pretty simple so it may break if it is used in a more complicated.
Circular includes are detected and treated as an error.
2018-02-17 18:59:11 +01:00
Fabian Woltermann 16ed58f403 Print a helpful reminder about the camera controls 2018-02-17 16:25:15 +01:00
Fabian Woltermann 5ac2571efa Clamp the lab camera's phi component to [0.01, 3.13] to avoid locking issues 2018-02-17 11:56:26 +01:00
Fabian Woltermann 7dfa5b5739 move this variable initialization out of the switch statement 2018-02-17 10:46:59 +01:00
m!m 0178374b98 Merge pull request #1606 from The-E/NewLab
Use mission backgrounds in the F3 lab
2018-02-16 11:26:51 +01:00
Fabian Woltermann 738e4a8153 Remove unused variable 2018-02-16 09:49:11 +01:00
Fabian Woltermann 1a4181fb67 Merge pull request #1609 from Flip-Sandwich/master
Fixes beam behaviour with additive/cap/etc damage types
2018-02-16 09:47:32 +01:00
faceman 85c2b3a7f0 Removes a magic number from ship.cpp 2018-02-16 16:08:45 +11:00
faceman 508b8a176b Fixes beam behaviour with additive/cap/etc damage types 2018-02-16 15:12:25 +11:00
Fabian Woltermann ca313ae17f Addressing CI issues 2018-02-15 14:41:14 +01:00
Fabian Woltermann 87bb2cbcc7 Remove debris rendering for now 2018-02-15 14:19:59 +01:00
Fabian Woltermann 9e673ff7fe light_reset needs to be called on every frame.
this also adds a trace scope to sunspot processing
2018-02-15 11:09:53 +01:00
Fabian Woltermann 126b6718db Reset the background window when it's closed 2018-02-15 11:01:34 +01:00
Fabian Woltermann b0fc182fab Fix crash when switching between weapons and ships 2018-02-15 10:44:45 +01:00
Fabian Woltermann 158292afba We can't show tech or external models yet 2018-02-15 10:35:25 +01:00
Fabian Woltermann e334c1f736 Specify all values explicitly 2018-02-15 10:21:13 +01:00
Fabian Woltermann f6fa053d94 Addressing feedback 2018-02-15 10:17:32 +01:00
Fabian Woltermann 4e24fba7fa Make sure the index is always incremented 2018-02-15 10:09:37 +01:00
Fabian Woltermann 0ea638f520 Fix an uninitialized variable being stuffed into a vector 2018-02-15 10:05:46 +01:00
Fabian Woltermann d75ec93484 Merge pull request #1604 from Flip-Sandwich/master
Consistent beam damage per frame regardless of time acceleration
2018-02-14 20:11:18 +01:00
Fabian Woltermann 468a9f280a Merge pull request #1607 from asarium/fix/aiProfilesWarning
Don't include the default ai_profiles system in CFile
2018-02-14 20:10:15 +01:00
Fabian Woltermann 69f4fa60f5 Remove unused variables 2018-02-14 17:10:26 +01:00
Fabian Woltermann 95ed536225 change the light type to an enum class 2018-02-14 17:07:42 +01:00
asarium 96d3eebad9 Don't include the default ai_profiles system in CFile
This fixes a warning caused by parsing the default ai_profiles table
twice. The default table was moved out of the data/tables folder and
into a special builtin category which will not be included in CFile.
2018-02-14 16:45:04 +01:00
Fabian Woltermann 3b21b2469f A clean, up-to-date patch of the new lab code 2018-02-14 16:19:38 +01:00
Fabian Woltermann cbe1d20fcc Merge pull request #1310 from asarium/feature/inMemoryCfile
Add support for accessing default files with CFile
2018-02-14 11:45:34 +01:00
m!m 3d3bbb5dc4 Merge pull request #1602 from The-E/RadarRangeWarning
Downgrade the invalid radar range error in the plr reader code to a warning
2018-02-14 11:12:34 +01:00
asarium 4c5b1c679b Add support for accessing default files with CFile
This allows to use more complex file structures in the executable
without requiring that those exist as real files. The rest of the code
does not need to handle the difference between a default file and a real
file anymore which means that it's now possible to embed image files
into the executable since bmpman only needs to use the standard CFile
API.

I added two tests which check if the default file can be found and
opened and if a mod file overrides the default file which should always
be possible.
2018-02-14 11:02:59 +01:00
faceman 65941e2e84 forgot to specify that 0.0f is indeed a float 2018-02-14 11:04:54 +11:00
faceman 538adf1bf6 Negative damages should not heal subsystems IMO 2018-02-14 11:00:34 +11:00
faceman a6d8b6b5fa Consistent beam damage per frame regardless of time acceleration 2018-02-14 10:41:49 +11:00
Fabian Woltermann 7fb5f08530 Merge pull request #1603 from asarium/fix/shipSoundGhostCrash
Fix assertion failure in ship_get_sound
2018-02-13 09:42:39 +01:00
asarium ffad093153 Fix assertion failure in ship_get_sound
This assertion could be hit if the player died and the engine tried to
play a sound for the now destroyed ship. Since the existing code already
had a check for the case that the object is an observer I just added
another case for OBJ_GHOST.
2018-02-12 19:46:25 +01:00
Fabian Woltermann 6a73d8f9d0 Having an invalid radar range in the pilot file should not be a fatal error. 2018-02-12 12:08:13 +01:00
m!m a0a88128ef Merge pull request #1599 from The-E/DirectionalLightFix
Make sure directional lights are always rendered
2018-02-12 11:40:05 +01:00
Fabian Woltermann 6fad19c8bc More changes requested by CI 2018-02-12 10:40:56 +01:00
Fabian Woltermann 119b5d662b Addressing feedback and CI issues 2018-02-12 08:57:39 +01:00
Fabian Woltermann 0b612c2f1a Remove an unused #define 2018-02-10 14:20:45 +01:00
Fabian Woltermann 8aee62b818 Make sure directional lights are always rendered; this kinda spiralled out into a bit of general cleanup regarding the lighting code. 2018-02-10 14:09:32 +01:00
m!m 1314b8634a Merge pull request #1597 from asarium/fix/int_list_warning
Fix off-by-one error in stuff_int_list
2018-02-10 12:12:59 +01:00
asarium b557985e90 Fix off-by-one error in stuff_int_list 2018-02-10 10:54:12 +01:00
Fabian Woltermann 4f43a2edf3 Merge pull request #1594 from The-E/MissileLightingdefault
Remove the -missile_lighting commandline parameter
2018-02-09 09:35:16 +01:00
m!m 6083c89b45 Merge pull request #1596 from asarium/fix/parse_int_list_errors
Improve error messages in stuff_int_list
2018-02-08 21:57:15 +01:00
asarium eefba9159a Improve error messages in stuff_int_list
This also converts an assertion into a proper error message which would
contain the actual file and line number.
2018-02-08 19:48:10 +01:00
m!m 8fed2fcfe3 Merge pull request #1590 from The-E/OGLDebugMessageSpamFix
Reduce the amount of Debug message spam due to non-fatal OGL warnings
2018-02-08 19:12:06 +01:00
Fabian Woltermann d149dd18b5 Use correct bit math operator 2018-02-07 15:32:37 +01:00
Fabian Woltermann a7d624f82d Add -missile_lighting to the deprecated flags 2018-02-06 16:38:52 +01:00
m!m aaab3fa03b Merge pull request #1589 from The-E/DebugFilterFix
Fix for debug_filters defaulting to +Parse
2018-02-06 14:20:41 +01:00
Fabian Woltermann 0d51cb0d14 Merge branch 'MissileLightingdefault' of https://github.com/The-E/fs2open.github.com into MissileLightingdefault 2018-02-05 16:21:55 +01:00
Fabian Woltermann 1c56d9f497 Remove the -missile_lighting commandline parameter 2018-02-05 16:18:15 +01:00
Fabian Woltermann dfc8cd1168 Remove the -missile_lighting commandline parameter 2018-02-05 16:16:55 +01:00
Fabian Woltermann ccaa766474 Merge pull request #1486 from asarium/opengl/combinedVertexBuffers
Pack vertex and index data into one buffer
2018-02-04 16:16:45 +01:00
Fabian Woltermann 741c28d785 Merge pull request #1565 from asarium/ci/gcc7
Add GCC 7 configuration for Travis CI
2018-02-04 16:15:25 +01:00
Fabian Woltermann d73a21a579 Fix variable shadowing warning 2018-02-03 23:02:19 +01:00
Fabian Woltermann 5b8f4343a3 Since OGL debug messages are only useful for coders, most of the time, we shouldn't print them to the general log unless they're actually critical 2018-02-03 22:58:43 +01:00
Fabian Woltermann 310785a961 Somehow, this loop to search for an existing debug filter did not work correctly anymore? 2018-02-03 22:38:53 +01:00
Fabian Woltermann 9029aad64d Merge pull request #1586 from asarium/fix/1579_workaround
Add a workaround for clipping planes on NVIDIA
2018-01-30 20:58:07 +01:00
asarium acc018507b Pack vertex and index data into one buffer
This changes the model loading code such that all index and vertex data
is packed in a single GPU buffer for each data type (index and vertex
data are still in separate buffers). This reduces the amount of buffer
rebinding needed when rendering a scene which will reduce the CPU
overhead. Furthermore, this opens up possibilities of future
improvements for which it is beneficial if all data is in the same
buffer (e.g. MultiDrawIndirect rendering).

To manage where to put the data in the GPU buffer I implemented a
custom HeapAllocator which manages where data can be put. It uses a very
primitive first-fit algorithm but that is sufficient for this usage
type. This does add quite a lot of overhead while allocating GPU model
data (I did some tracing and some allocation calls took as long as
130ms).

This fixes #1457.
2018-01-27 13:54:36 +01:00
asarium 25698b4534 Add a workaround for clipping planes on NVIDIA 2018-01-27 13:40:04 +01:00
Fabian Woltermann a2f6897c43 Merge pull request #1581 from asarium/feature/luaVersionCheck
Add lua function for checking the engine version
2018-01-26 17:05:24 +01:00
Fabian Woltermann 0777f24f08 Merge pull request #1583 from The-E/JumpnodeNameAssertion
Improve the JumpNode::SetName assertion to be readable by non-coders
2018-01-22 10:28:11 +01:00
Fabian Woltermann ed45baa843 Improve the JumpNode::SetName assertion to be readable by non-coders 2018-01-21 23:38:58 +01:00
m!m 13ff2ec907 Merge pull request #1582 from asarium/fix/nanovgPerformance
Add simple NanoVG draw buffer for better performance
2018-01-20 20:51:49 +01:00
asarium e795327a3f Add simple NanoVG draw buffer for better performance
This improves the rendering performance of the target hotkey brackets a
bit which caused a significant slowdown previously.
2018-01-20 18:32:39 +01:00
asarium 3c238d61e2 Add lua function for checking the engine version
This can be used to check if an API function is available in the current
version of the engine without causing runtime errors.
2018-01-20 16:37:31 +01:00
m!m 2d3e7e54e8 Merge pull request #1534 from asarium/fix/fs2netdSigbus
Fix SIGBUS crash in fs2netd
2018-01-18 16:14:54 +01:00
Tyler Blount 8ba05c1c3d Merge pull request #1578 from SamuelCho/reflection_blur_fix
Fix gloss-dependent blurred reflections
2018-01-16 09:01:54 -07:00
Tyler Blount 277962974c Merge pull request #1576 from SamuelCho/specularFixes
Specular lighting shader fixes
2018-01-15 23:17:40 -07:00
SamuelCho eab5b8b40a Allocate additional immutable storage for glGenerateMipMap when generating cube map mip levels if there's only one level 2018-01-15 22:15:04 -08:00
SamuelCho 842554e237 Flipped specular minimum floor to be done before gamma correction. Adjusted minimum specular value to 0.03 from 0.04 since that's Substance Painter's minimum. Brought back fresnel factor from the Blinn Phong function since that's needed for retail models. 2018-01-15 13:47:48 -08:00
Fabian Woltermann 563dc35dea Merge pull request #1575 from ngld/fix/setSubspaceDrive
Fix set-subspace-drive on debug builds and make the sexp_val Assert more helpful
2018-01-14 11:21:16 +01:00
ngld 3fc6958f88 Fix set-subspace-drive on debug builds and make this Assert more helpful 2018-01-14 02:48:11 +01:00
Fabian Woltermann a886a1659c Merge pull request #1574 from asarium/opengl/decalSystem
Add screen space decal rendering system
2018-01-13 14:36:36 +01:00
asarium 99f69c903e Add screen space decal rendering system
This allows to render screen space decals into the deferred lighting
buffers no matter how complex the underlying geometry is.

Currently there is only limited support for using this in the engine.
Only weapon impact decals are supported at the moment for testing
purposes.
2018-01-12 17:09:49 +01:00
m!m 830fd70f9e Merge pull request #1573 from SamuelCho/ggx
Replaced Blinn-Phong BRDF with GGX BRDF
2018-01-12 09:49:54 +01:00
m!m c4ff34970f Merge pull request #1572 from MageKing17/bugfix/unicode-distance
Correct backwards arguments in unicode::num_codepoints().
2018-01-12 09:31:52 +01:00
SamuelCho f216b8bf7f Replaced Blinn-Phong BRDF with GGX BRDF 2018-01-11 22:25:43 -08:00
MageKing17 0ec2c7fef0 Correct backwards arguments in unicode::num_codepoints().
When Unicode_text_mode was false, unicode::num_codepoints() would return (the size_t equivalent of) a negative number, because it was checking the distance from end to start instead of the distance from start to end.
2018-01-11 20:40:42 -08:00
MageKing17 1f70fb2bf2 Merge pull request #1570 from niffiwan/fix/default_volumes_pilot_create
set default volumes on pilot create
2018-01-11 10:57:52 -08:00
niffiwan 304a6a3a0d define the defaults volumes correctly 2018-01-11 19:56:12 +10:00
m!m ec6bea233b Merge pull request #1569 from chief1983/lib/sdl207
Upgrade the included SDL libs to 2.0.7.
2018-01-11 10:28:58 +01:00
niffiwan 9e495d7f94 set default volumes on pilot create
previously newly created pilots inherited the volumes from the last
pilot
2018-01-11 12:08:28 +10:00
Cliff Gordon 0344fd6e35 lib/sdl207: Also update the hash to use the new SCP Prebuilt lib version. 2018-01-10 10:02:58 -06:00
Cliff b8b7d41786 lib/sdl207: Upgrade the included SDL libs to 2.0.7. 2018-01-09 19:43:52 -06:00
asarium 3410822d9d Add GCC 7 build configuration for Travis CI
There are a few new warnings in GCC7 so this makes sure that no warning
gets missed by our CI setup. The new configuration should be updated to
the newest GCC version whenever possible.
2018-01-09 10:36:33 +01:00
MageKing17 aea63832ed Merge pull request #1568 from asarium/fix/1561
Reset loaded ship object when closing the F3 lab
2018-01-07 15:45:54 -08:00
MageKing17 1ee1886a9a Merge pull request #1567 from asarium/feature/wingLuaParameter
Add support for passing various parameter types to Lua SEXPs
2018-01-07 15:45:27 -08:00
MageKing17 c0a8ceb48f Merge pull request #1566 from asarium/fix/invalidSexpException
Fix game crash when a lua SEXP is not initialized properly
2018-01-07 15:44:46 -08:00
MageKing17 6bdbbd5c40 Merge pull request #1564 from asarium/build/cleanupOpenALLibs
Remove unnecessary OpenAL binaries in main repository
2018-01-07 15:42:13 -08:00
MageKing17 c66839a9bf Merge pull request #1562 from asarium/fix/readyroomCrash
Reset campaign room text pointers when freeing campaign data
2018-01-07 15:39:26 -08:00
asarium 40ba3162dc Reset loaded ship object when closing the F3 lab
The crash described in #1561 was caused by a NULL ai profile. The
profile was not set because the lab system already had a loaded ship
object (see line 2230). These changes make sure that the loaded ship
object is deleted before closing the lab system which ensures that the
ai profile is set the next time the lab is initialized.

This fixes #1561.
2018-01-07 14:31:42 +01:00
asarium e81547ae88 Add support for weapon class SEXP parameters 2018-01-07 12:26:33 +01:00
asarium 7577018bd3 Add support for ship class SEXP parameters 2018-01-07 12:24:18 +01:00
asarium 2181512949 Add support for passing wing parameters to Lua SEXPs
This was requested by Axem on Discord.
2018-01-06 19:28:45 +01:00
asarium dff5e4c21d Fix game crash when a lua SEXP is not initialized properly
These changes make sure that this situation is detected properly and an
informative error message is shown.
2018-01-06 19:11:48 +01:00
Fabian Woltermann d7ea260607 Merge pull request #1546 from asarium/fix/wrongMemset
Fix two minor issues detected by GCC7 warnings
2018-01-05 14:53:51 +01:00
m!m 7f7ed74bd6 Merge pull request #1563 from asarium/feature/hudTracingScopes
Add tracing scopes for HUD rendering
2018-01-05 12:30:10 +01:00
m!m 0df6c22216 Merge pull request #1547 from asarium/build/ccache
Enable ccache when available
2018-01-05 12:20:30 +01:00
asarium e8ab065bde Remove unnecessary OpenAL binaries in main repository
This is now handled by the prebuilt packages and not needed anymore.
2018-01-05 12:16:18 +01:00
asarium f79b83c60b Enable ccache when available
This will automatically enable ccache when it is detected on the system
and use it for faster compilations.
2018-01-04 20:52:03 +01:00
Fabian Woltermann 3ab6e43254 Merge pull request #1558 from The-E/revert_1555
Revert changes from #1555
2018-01-04 20:24:08 +01:00
asarium abbef793fc Add tracing scopes for HUD rendering
While debugging a performance issue reported on Discord I noticed that
the HUD rendering code does not have any tracing scopes. This adds a few
tracing scopes to that code to make performance debugging a bit easier.
2018-01-04 20:19:10 +01:00
m!m bd85f61971 Merge pull request #1560 from The-E/fix_1559
Sanity checking in maybe_play_flyby_snd
2018-01-04 16:23:29 +01:00
asarium 47967cb72a Reset campaign room text pointers when freeing campaign data
Previously the campaign room caused a heap-use-after-free error
(detected by AddressSanitizer) when loading the campaign failed two
times. This fixes the error by resetting the text pointers to their
default values when freeing the campaign list data.
2018-01-04 14:41:42 +01:00
Fabian Woltermann 7f56037369 Fully revert this 2018-01-04 13:39:16 +01:00
Fabian Woltermann 659828c213 If no flyby sounds are defined for a species, do not attempt to play any. 2018-01-04 11:10:06 +01:00
Fabian Woltermann 2c4884595e Revert changes from #1555 2018-01-04 10:47:57 +01:00
Fabian Woltermann 1621bd169b Merge pull request #1556 from asarium/fix/1554
Make sure updating a texture uses the right texture unit
2018-01-04 09:16:08 +01:00
Fabian Woltermann c496a08ab1 Merge pull request #1557 from asarium/fix/1555
Use correct attachment for depth/stencil buffer
2018-01-03 19:46:38 +01:00
m!m 012e37afb9 Merge pull request #10 from The-E/fix/1555
This seems to stop the flood.
2018-01-03 18:37:59 +01:00
Fabian Woltermann 4fc1183622 If we change the depth and stencil attachments in one place, we need to change them in all places. 2018-01-03 16:09:22 +01:00
asarium 1eaa67bb5b Use correct attachment for depth/stencil buffer
This should be the correct way to set the combined depth/stencil buffer.
This has not been tested yet since I do not have a GPU which causes
these issues.

This fixes #1555.
2018-01-03 13:45:43 +01:00
asarium bf74f29634 Make sure updating a texture uses the right texture unit
The normally faster version that was used before misbehaved if that
texture unit already used the specified texture object which caused the
glTexSubImage3D to cause out of bounds issues some times.

This fixes #1554.
2018-01-03 13:33:03 +01:00
m!m 6159e13162 Merge pull request #1551 from asarium/feature/messageSexpParameters
Add ability for passing messages to scripted SEXPs
2018-01-03 11:52:05 +01:00
asarium 1bd09a91d3 Add ability for passing messages to scripted SEXPs 2018-01-01 19:40:35 +01:00
MageKing17 8cf0e8eb1d Merge pull request #1550 from chief1983/fix/1541_mac_chdir
Only change directory on MacOS when parent process path is /sbin/launchd.
2017-12-30 17:16:51 -08:00
chief1983 2dcb75057c fix/1541_mac_chdir: Only change directory on MacOS when parent process path is /sbin/launchd. 2017-12-30 16:39:34 -06:00
asarium d95f173f26 Fix another sprintf warning of GCC7 2017-12-28 10:52:56 +01:00
asarium 47b21f6792 Fix wrong usage of memset
This caused a warning in GCC7 which is fixed by this. This will also
initialize the array properly since the previous version may not have
worked correctly even if the entire array woudld have been written (on
all supported platform it would have worked since repeating -1 on all 4
bytes of an int will still produce -1).
2017-12-28 10:50:10 +01:00
m!m 5ec8896c4a Merge pull request #1545 from ngld/fix/waveFileMissing
Log a proper error message if WaveFile::Open tries to load a missing file
2017-12-28 10:26:10 +01:00
ngld 560b49158b Log a proper error message if WaveFile::Open tries to load a missing file 2017-12-28 00:33:16 +01:00
Fabian Woltermann c109dc6aca Merge pull request #1539 from asarium/fix/shipSexpParamters
Pass ship variables as actual handles to scripts
2017-12-25 17:40:30 +01:00
m!m 581e5b0242 Merge pull request #1543 from asarium/fix/unicodeSpeech
Convert speech text properly to wide string
2017-12-24 12:44:15 +01:00
asarium ace3fc619e Convert speech text properly to wide string
The previous code could only handle ASCII data correctly but this new
code is also able to handle UTF-8 data correctly by using the Windows
API function MultiByteToWideChar. Since the conversion only happens in
Windows-only code this is not a portability issue.

This fixes an issue reported on the forums where non-ASCII text was not
spoken correctly by the TTS system.
2017-12-23 20:30:55 +01:00
m!m 7d418d50ce Merge pull request #1542 from devnexen/ffmpeg_decoder_fix
this codec layer handling not present but only from a certain version.
2017-12-23 13:10:07 +01:00
David Carlier ebd24341d4 this codec layer handling not present but only from a certain version. 2017-12-23 08:49:52 +00:00
asarium e8c80dbefc Pass ship variables as actual handles to scripts
This was requested by Axem on the forums.
2017-12-22 09:26:24 +01:00
m!m 68e19a19c5 Merge pull request #1331 from asarium/feature/scriptedSEXPs
Add ability to dynamically add new SEXPs at runtime
2017-12-20 12:41:05 +01:00
asarium f780d9e22a Add ability to dynamically add new SEXPs at runtime
This add a system for adding generic instances of the DynamicSEXP class
to the SEXP system. The only implementation at the moment is the LuaSEXP
which is used by the mn.addSEXP lua API to allow Lua to add new SEXPs.

Since this requires that FRED also runs lua scripts I added a mod table
option to enable scripting in FRED. Since the current scripts are not
built with FRED in mind it would likely break all these scripts if FRED
would be opened with normal scripting enabled.

This fixes #1320.
2017-12-20 10:45:40 +01:00
m!m c5117cf55e Merge pull request #1538 from TRBlount/fix/apply_recoil
Remove second instance of apply recoil flag in Weapon_Info_Flags
2017-12-20 10:28:32 +01:00
TRBlount f9704ebd89 Remove second instance of apply recoil flag in Weapon_Info_Flags 2017-12-19 12:41:53 -07:00
Fabian Woltermann eb738b3ef7 Merge pull request #1518 from asarium/fix/additionalFFmpegLogging
Add additional logging output for FFmpeg library version
2017-12-18 21:31:29 +01:00
Fabian Woltermann f04debfb36 Merge pull request #1537 from asarium/fix/parsingCrash
Fix some FRED issues
2017-12-18 21:30:47 +01:00
asarium aa8fb89a17 Fix unreadable FRED tooltip
I forgot to set the alpha blend mode in the NanoVG changes which meant
that the code used additive blending by default which is not good if the
color in use is black. This sets the blend mode to the value that
corresponds to the values used by the NanoVG reference code.
2017-12-18 19:04:36 +01:00
asarium 44e5f89e41 Fix crash in parsing code
The `nullptr` check was removed by mistake.
2017-12-18 18:28:49 +01:00
Fabian Woltermann fee0b900de Merge pull request #1489 from asarium/opengl/betterModelClipping
Use built-in OpenGL clipping planes for model transforms
2017-12-16 10:43:01 +01:00
Fabian Woltermann 6b209223ee Merge pull request #1531 from asarium/build/bundleOpenAL
Include OpenAL Soft DLLs as part of the build
2017-12-16 10:42:30 +01:00
Fabian Woltermann cb06c73b6a Merge pull request #1527 from asarium/feature/scriptedXSTRs
Add support for translating strings in scripts
2017-12-16 10:33:48 +01:00
Fabian Woltermann 7ab8a96903 Merge pull request #1526 from asarium/feature/xstrStringVars
Add support for setting string variables from a XSTR
2017-12-16 10:33:06 +01:00
Fabian Woltermann a58376404d Merge pull request #1523 from asarium/feature/movieSubtitles
Add localized subtitle support to the video player
2017-12-16 10:32:31 +01:00
Fabian Woltermann cfe89f411b Merge pull request #1535 from chief1983/always_preload_snd
Always Preload Game Sounds
2017-12-11 19:34:57 +01:00
m!m 91c9417d3e Merge pull request #1424 from chief1983/fix/470_attempt_2
Fix for #470: Proposal 2
2017-12-11 00:05:45 +01:00
Cliff f37c519b79 always_preload_snd: Is there ever a good reason not to preload mission sounds at this point? 2017-12-10 13:18:58 -06:00
Cliff Gordon 4dd194f4d6 fix/470_attempt_2: One more thing missing. 2017-12-10 13:16:42 -06:00
Cliff Gordon b38367b22f fix/470_attempt_2: Some more cleanup from this being copied from a set of functions and structs. 2017-12-10 13:16:42 -06:00
Cliff Gordon 72517ff9a2 fix/470_attempt_2: I should probably read my examples closer. Just make these local variables since I didn't bring in the struct from the example as it was overkill for us. 2017-12-10 13:16:42 -06:00
Cliff Gordon c3e212094e fix/470_attempt_2: Try to fix SIGPIPE crash using Kroki's example. 2017-12-10 13:16:42 -06:00
asarium 5f7721f300 Fix SIGBUS crash in fs2netd
This was reported by chief1983 on Discord. The standalone server crashed
with a SIGBUS error caused by an invalid socket file handle in
FS2NetD_DataReady(). This should fix that by adding additional checks
where necessary to make sure that our socket is valid when the socket
functions are used.
2017-12-10 19:42:56 +01:00
Fabian Woltermann 9e9378dcb6 Merge pull request #1533 from asarium/fix/jpegInterfaceCrash
Fix crash when using JPEGs as interface bitmaps
2017-12-10 18:39:03 +01:00
asarium 9b9041513d Fix crash when using JPEGs as interface bitmaps 2017-12-10 13:29:16 +01:00
Fabian Woltermann 51aac78080 Merge pull request #1529 from asarium/cleanup/noParseEofChar
Replace the special EOF char value with a standard null byte
2017-12-10 12:39:56 +01:00
m!m 3dd21f6cb6 Merge pull request #1532 from z64555/fix/mpshield_hits
Moves player control check for modelpoint shields into…
2017-12-10 12:22:01 +01:00
z64555 a42b27c0b8 Moves player control check for modelpoint shields into hud_augment_shield_quadrant(). AI ships can now use shield_transfer() on quadrant indices larger than 3. 2017-12-08 15:01:10 -06:00
asarium ca73920b8e Replace the special EOF char value with a standard null byte
This was an issue since UTF-8 encoded text can contain -128 as part of
an encoding sequence which causes a lot of issues for the parsing code.
I could not find any indication why the original code didn't use null
bytes from the start and I also couldn't find any code that would break
because of this. If anyone knows why this was done like this please let
me know.
2017-12-07 14:42:01 +01:00
asarium 17374106d1 Include OpenAL Soft DLLs as part of the build
This will remove the dependency on a system version of OpenAL and also
enable the advanced sound code for everyone. This removes the ability to
use a custom OpenAL version but removing the only system dependency we
currently have is worth a lot more than being able to use a custom
OpenAL version.
2017-12-06 10:42:02 +01:00
asarium 6da5302d34 Add localized subtitle support to the video player
This adds support for displaying subtitles embedded in movie files. This
supports files with multiple subtitle streams where each stream contains
the subtitles for one language. When the movie file is opened, the
stream for the currently active language will be used and displayed.

This resolves one of the points mentioned in #1522.

This also depends on PR #1484.
2017-12-05 12:04:13 +01:00
asarium d0a1efacb8 Improve video player API
This moves all the cutscene specific code out of the movie player code
and into the cutscene code so that the movie player can be reused for
usage in other environments.

This is required for #1041 since an implementation of that feature would
reuse the movie player code of the cutscene code but without all the
main loop stuff.
2017-12-05 12:01:50 +01:00
MageKing17 8168099eac Merge pull request #1530 from asarium/fix/fredSpheres
Fix usage of wrong buffer handles in opengl_draw_sphere()
2017-12-05 00:56:31 -08:00
asarium ae943503cb Fix usage of wrong buffer handles in opengl_draw_sphere()
This fixes another issue reported by Trivial Psychic on the forums.
2017-12-04 18:06:37 +01:00
asarium 4368db845d Add support for setting string variables from a XSTR
This allows to set string variables to localized values which will make
translating missions much easier.

This resolves one of the points mentioned in #1522.
2017-12-04 13:12:30 +01:00
m!m c25163e265 Merge pull request #1528 from asarium/fix/labGhosting
Enable all color channels before doing a clear
2017-12-04 12:58:17 +01:00
asarium 4bf9277c10 Enable all color channels before doing a clear
If the previous rendering operation left the color mask in any other
state than completely enabled then the clear will only affect the
enabled channels. This makes sure that all channels are enabled before
doing the clear.

This fixes an issue reported on the forums:
https://www.hard-light.net/forums/index.php?topic=94200.msg1859118#msg1859118
2017-12-04 11:56:47 +01:00
asarium 0bcdf19851 Add mission load screen scripting hook
This also includes a scripting function for retrieving the title of the
current mission.

This resolves point 4 of #1522.
2017-12-03 18:51:06 +01:00
asarium c4095d1af1 Add support for translating strings in scripts
This allows to use the XSTR mechanism in script to make translating
script text possible. This is compatible with the existing XSTR format
so automatic tstrings.tbl generator tools should work fine with this.

This resolves point 2 of #1522.
2017-12-03 18:51:06 +01:00
MageKing17 5d8f779cff Merge pull request #1416 from asarium/feature/onlyUnicode
Add true Unicode support
2017-12-03 09:32:04 -08:00
m!m 6f2592e733 Merge pull request #1525 from asarium/fix/disappearingShipSelection
Add a few graphics debug scropes to the ship selection
2017-12-02 22:20:01 +01:00
asarium 528a43952e Add a few graphics debug scropes to the ship selection
I added these while investigating the issue which was fixed in the
last commit and more debug scopes are always useful.
2017-12-02 19:34:36 +01:00
m!m 62d1f1978b Merge pull request #1475 from asarium/opengl/genericNanoVG
Add a NanoVG renderer using the generic rendering API
2017-12-02 19:34:01 +01:00
asarium b9b556c7a5 Add a NanoVG renderer using the generic rendering API
One of the main points of contention when adding the NanoVG based
TrueType text rendering was that it required an external Opengl
renderer which may interfere with our rendering engine by changing
OpenGL state without telling the rest of the engine. Since the rendering
interface for NanoVG is abstract and can be easily replaced, I did just
that and replaced it with an implementation that uses only generic
graphics functions without relying on the specific graphics API.

This will improve the interoperability of NanoVG with our engine and
should make later changes to the rendering engine easier since there is
no external rendering code which may interfere with our own code.
2017-12-02 18:31:00 +01:00
m!m 16b0db8eb9 Merge pull request #1524 from asarium/fix/3dSoundWarning
Only display 3D sound warnings for mods with 3.8.0 support
2017-12-02 17:20:43 +01:00
asarium 2c36ea35b4 Only display 3D sound warnings for mods with 3.8.0 support
This was an issue since a lot of mods used wrong sounds and after the
FFmpeg changes the code would display a warning for those sounds by
default. This will restore the old behavior of printing the warning to
the log where it is easier to ignore if the mod does not explicitly
support 3.8.0.
2017-12-01 12:06:23 +01:00
asarium 43e540cc4c Add true Unicode support
This adds proper Unicode support by allowing the parse system to read
UTF-8 encoded files. The new mode is controlled by a mod option which
allows older mods to continue using the legacy text encoding.

That option changes the behavior of several systems in FSO. It disallows
the usage of Volition fonts since they don't support Unicode encoding
and changes a few usages of special characters to their unicode
counterparts of generic rendering solutions.

This fixes #1415.
2017-11-30 13:26:20 +01:00
Fabian Woltermann 67627bd786 Merge pull request #1490 from asarium/opengl/vertexAttribBinding
Use OpenGL vertex array objects for better performance
2017-11-30 12:57:39 +01:00
m!m ea0c4b7b78 Merge pull request #1519 from asarium/build/fixAppimageLibraryPath
Fix LD_LIBRARY_PATH value in AppImage runs
2017-11-23 15:07:27 +01:00
Fabian Woltermann 29e56bb19a Merge pull request #1520 from asarium/fix/randomRangeWrongField
Fix wrong field usage in RandomRange
2017-11-23 15:05:13 +01:00
asarium 57da3e1ef6 Fix wrong field usage in RandomeRange 2017-11-23 12:53:30 +01:00
asarium 16ac19946f Fix LD_LIBRARY_PATH value in AppImage runs
The previous version used PATH instead of LD_LIBRARY_PATH which may have
caused some issues if the system is configured in a way that depends on
the value of LD_LIBRARY_PATH. It also broke launchers that tried to fix
library issues by changing LD_LIBRARY_PATH.
2017-11-22 11:31:04 +01:00
asarium e319b6f941 Use built-in OpenGL clipping planes for model transforms
This changes the batched transform code so that instead of using discard
in the fragment shader it uses the built-in clipping capabilities of
OpenGL for removing invisible sub models. This improves performance in
GPU-limited scenes by ~1ms if shadows are enabled.
2017-11-22 10:32:20 +01:00
asarium 8c88b68327 Use OpenGL vertex array objects for better performance
The original OpenGL Core changes only used a single vertex array object
for specifying the data layout of our vertex data. This uses the OpenGL
extension GL_ARB_vertex_attrib_binding to extend that so that each
vertex_layout uses a separate vertex array object which should improve
performance by reducing the CPU overhead while switching the vertex
layout. Since we need to use offsets into the vertex buffers at some
points this can not be done with the core functions since those do not
support specifying an offset when binding a vertex buffer.
GL_ARB_vertex_attrib_binding does support that and also features an
improved API for specifying the vertex layout. If that extension is not
available then the rendering engine will fall back to the current code.

In CPU intensive scenes I observed a frametime improvement of 1-2 ms.
2017-11-21 12:02:10 +01:00
asarium e75ed62692 Add additional logging output for FFmpeg library version
I had to debug some ffmpeg library issues and added these additional log
statements. They may be useful in the future.
2017-11-21 10:55:09 +01:00
MageKing17 748857ca2f Merge pull request #1517 from asarium/fix/1516
Fix PCX alpha color correction
2017-11-20 13:43:56 -08:00
m!m bff8231d87 Merge pull request #1509 from asarium/feature/jsonFlagPrinting
Add support for printing command line flags in JSON output
2017-11-20 22:10:33 +01:00
MageKing17 29087a3237 Merge pull request #1511 from asarium/build/gcc7Warnings
Fix new warnings generated by GCC 7
2017-11-20 12:20:30 -08:00
asarium a228a127e2 Fix PCX alpha color correction
This is a bugfix for an issue introduced in
72a797f732 which broke 8 bits-per-pixel
alpha bitmap reading.

This fixes #1516.
2017-11-20 13:17:22 +01:00
asarium 2692240ed9 Add additional information to JSON output 2017-11-19 13:27:56 +01:00
asarium a47dcc0548 Fix fall-through warnings introduced by GCC7 2017-11-19 12:12:42 +01:00
m!m 9fed19d4fc Merge pull request #1505 from MageKing17/feature/bmpman-usage
Add in-game BMPMAN usage display.
2017-11-19 11:56:03 +01:00
MageKing17 9446e61587 Add in-game BMPMAN usage display.
Can be enabled with the "-bmpmanusage" command-line option, toggled via the debug console, or toggled via a debug/cheat key combo (`+B).
2017-11-18 16:55:58 -08:00
MageKing17 1ffd0d3ef8 Merge pull request #1512 from asarium/feature/freddocsCfile
Search for fred docs using cfile
2017-11-18 14:50:43 -08:00
MageKing17 1a94018fb4 Merge pull request #1515 from MageKing17/bugfix/fred-close-exception
Avoid exception when closing FRED related to bm_release().
2017-11-18 14:49:14 -08:00
MageKing17 e8ef727a19 Avoid exception when closing FRED related to bm_release().
Now that BMPMAN dynamically allocates the bm_bitmaps array, and deallocates it in bm_close(), which is explicitly called by gr_close(), FRED generates an exception on close because of trying to release bitmap handles after bm_bitmaps has been deallocated and set to null. This is because gr_close() is called by CFREDView::OnDestroy(), but the mission textures aren't fully paged out until CMainFrame::OnClose() (well, technically, CMainFrame::OnClose() calls CFrameWnd::OnClose(), which calls CWinApp::CloseAllDocuments(), which calls CDocManager::CloseAllDocuments(), which calls CDocTemplate::CloseAllDocuments(), which calls CDocument::OnCloseDocument(), which calls CFREDDoc::DeleteContents(), which calls CFREDDoc::editor_init_mission(), which calls reset_mission(), which calls clear_mission(), which calls model_free_all(), which calls model_instance_free_all(), which calls model_unload() for every model, which calls model_page_out_textures(), which *finally* calls the crashing bm_release()). This commit moves the gr_close() call to CMainFrame::OnClose(), *after* it calls CFrameWnd::OnClose(), which avoids the exception as bm_bitmaps is still intact long enough for those final textures to be freed from it.
2017-11-18 04:38:03 -08:00
MageKing17 dfdfd59367 Merge pull request #1514 from MageKing17/feature/window-title
Window title overhaul.
2017-11-17 03:57:56 -08:00
asarium 4f7b718167 Fix sprintf warnings by checking the return value 2017-11-17 12:52:16 +01:00
MageKing17 b1046b1c1c Window title overhaul.
FSO now allows the window title to be specified via game_settings.tbl, some never-used function arguments were pruned at the same time, and fred.rc now receives version information (for the About dialogue and the title bar) from a cmake-generated header, so the version numbers get filled in properly. Speaking of FRED's About dialogue, it now displays the copyright symbol properly.
2017-11-17 02:51:36 -08:00
MageKing17 4663aed194 Merge pull request #1513 from MageKing17/bugfix/training-variable-timing
Move game_do_training_checks() to be right before goal processing.
2017-11-17 02:50:32 -08:00
MageKing17 a56432f5fc Move game_do_training_checks() to be right before goal processing.
In-mission events (SEXP chains that are used for directives and all mission logic) can sometimes call "training SEXPs", which depend on special variables set in the game_do_training_checks() function. However, this function was called near the end of game_frame(), well after mission_eval_goals() (which processes all mission events). This means that most training SEXPs wouldn't actually evaluate as true until the frame after whatever condition they were checking became fulfilled. This, combined with PR #1388 making the "targeted" SEXP actually use the appropriate variables (Players_target and Players_targeted_subsys), means that Diaspora's very first training mission's very first instruction (after launching from the launch tube, anyway) could not be completed, because the mission logic assumed that "key-pressed" and "targeted" would both return true on the same frame (which, after PR #1388, they did not).

This commit moves game_do_training_checks() to be called immediately before mission_eval_goals(), and therefore immediately after obj_move_all(), meaning Training_context_speed_set can become set the same frame the player's ship reaches the appropriate velocity and the relevant SEXPs can operate on the most up-to-date data available.
2017-11-16 23:26:05 -08:00
asarium 206ce536ec Search for fred docs using cfile
This will allow to put the FRED docs somewhere else instead of into the
root directory of a TC.
2017-11-14 23:15:58 +01:00
Fabian Woltermann d8ccf84452 Merge pull request #1482 from asarium/cleanup/sexpSCPString
Use SCP_strings and SCP_vectors in SEXP code
2017-11-14 09:35:44 +01:00
Fabian Woltermann bed9c13233 Merge pull request #1497 from z64555/cleanup/swarm_missiles
Refactors swarm_update_direction() a bit...
2017-11-14 09:34:30 +01:00
Fabian Woltermann 16993b236f Merge pull request #1479 from asarium/opengl/modelUniformBuffers
Use uniform buffer blocks for passing uniform data to shaders
2017-11-14 09:33:45 +01:00
Fabian Woltermann 94f8d547e0 Merge pull request #1487 from asarium/cleanup/modelVertexStruct
Use a C-struct for managing GPU model data layout
2017-11-14 09:32:48 +01:00
MageKing17 b6908d10c4 Merge pull request #1470 from asarium/fix/1469
Fix error line reported by Lua Errors
2017-11-13 16:31:16 -08:00
m!m a54aa24a64 Merge pull request #1510 from TRBlount/fix/motion_debris_load
Fix motion debris anim loading in mission-set-nebula sexp
2017-11-12 11:57:28 +01:00
MageKing17 d083089e1d Merge pull request #1508 from The-E/lab_fix_window_background
Fix window drawing in the F3 lab
2017-11-11 23:30:40 -08:00
MageKing17 338436d590 Merge pull request #1506 from MageKing17/bugfix/music-table-section-skipping
Fix music table parsing when a soundtrack needs to be skipped.
2017-11-11 23:27:58 -08:00
asarium 1d2f778b76 Add support for printing command line flags in JSON output
This will output the flags data in a better format than the current
binary format. For determining if the JSON output should be used this
uses an optional parameter for -get_flags. The command line parsing does
not cause an error if a parameter is specified for an option that does
not support them. This way, the launcher can just pass "json_v1" to the
option and an old build will just silently ignore it and use the binary
format.
2017-11-11 20:29:36 +01:00
Fabian Woltermann aad1bbbb05 The labviewer window background got its width and height mixed up in 6dbd7c34, this fixes that 2017-11-11 20:24:10 +01:00
TRBlount 1e4bede8c5 Fix motion debris anim loading 2017-11-11 10:34:28 -07:00
MageKing17 38b331dc92 Fix music table parsing when a soundtrack needs to be skipped.
For some reason, commit 8b43ed823c moved the consumption of the "#Soundtrack End" token out of parse_soundtrack(), when if a soundtrack needs to be skipped (e.g. because it's in a .tbm, flagged with +nocreate, and the original doesn't exist), it will skip straight past "#Soundtrack End" to reach the next "#Soundtrack Start". It also changed how music tables are parsed so that they'll skip any junk data that happens to be between sections, which is atypical of how tables are parsed. This commit changes both of these things: "Soundtrack End" is once again consumed near the end of parse_soundtrack(), and the while loop uses check_for_string() instead of skipping to the start of a section.
2017-11-09 15:08:40 -08:00
m!m d3965b1f9d Merge pull request #1502 from MageKing17/feature/tabled-bmpman-limit
Allow BMPMAN slot limit to be defined by mod table.
2017-11-09 09:23:20 +01:00
asarium 986099a495 Handle bmpman shutdown explicitly
This was previously done with atexit which caused issues if bmpman was
initialized more than once which is the case for the unit tests.
2017-11-07 15:43:27 -08:00
MageKing17 07ff605c58 Attempt to guarantee that bm_bitmaps will only be allocated once.
Even if bm_init() gets called more than once, for whatever reason. Unless bm_close() is called first, in which case it will re-allocate, potentially with a different MAX_BITMAPS (but it's okay, because there shouldn't be any active handles to worry about if bm_close() was called).
2017-11-07 15:33:36 -08:00
m!m a8171c118f Merge pull request #1500 from TRBlount/fix/directional_glows
Fix directional glow issues
2017-11-06 12:44:47 +01:00
TRBlount 4b9c7b19aa Add comment regarding the length and radius of a beam muzzle glow 2017-11-04 12:24:12 -06:00
TRBlount 33d2294a49 Fix ramp up/down sequence and basic size/positioning of directional glows 2017-11-04 12:16:06 -06:00
MageKing17 8e558b2095 Move MAX_BITMAPS to bmpman.cpp/.h, use error_display() for warnings.
Per discussion on the PR. Also corrected sizeof(bm_bitmaps) to sizeof(bm_bitmaps[0]) * MAX_BITMAPS.
2017-11-04 08:52:56 -07:00
MageKing17 703bfab587 Merge pull request #1504 from asarium/fix/defaultMaterialClipPlane
Fix Assertion failure when rendering clip planes using default material
2017-11-04 07:39:40 -07:00
MageKing17 344502c436 Merge pull request #1495 from asarium/feature/betterSoundSets
Add support for multiple sounds in one game sound entry
2017-11-04 06:53:10 -07:00
asarium ef06593ed7 Fix Assertion failure when rendering clip planes using default material
The texture array changes introduced the default material which is
similar to the passthrough shader but allows to use texture arrays. The
vertex shader is the same as for the passthrough shader so that shader
also supports clipping planes.
2017-11-04 14:42:50 +01:00
MageKing17 a22b336bfe Merge pull request #1493 from asarium/fix/particleDirection
Fix several oversights and bugs in the particle effect code
2017-11-04 05:05:43 -07:00
MageKing17 37b81efea4 Allow BMPMAN slot limit to be defined by mod table.
bm_init() now dynamically allocates the bm_bitmaps array, and MAX_BITMAPS can be changed by the mod table.
2017-11-02 16:37:57 -07:00
MageKing17 7c6f99c68b Merge pull request #1501 from TRBlount/fix/DRADIS_visuals
Make DRADIS blips use decaying alpha
2017-11-01 15:31:09 -07:00
TRBlount f7b7aaead3 Use std::abs() 2017-10-31 15:21:54 -06:00
TRBlount 80dcefa0fc Add comment specifying functionality 2017-10-31 13:31:43 -06:00
TRBlount 27a70d545d Update using time since last sweep. 2017-10-31 13:13:59 -06:00
TRBlount e4614f01ba Fix DRADIS blip alpha 2017-10-30 16:07:54 -06:00
Tyler Blount e2d8502a3e Merge pull request #1488 from asarium/fix/renderTargetError
Fix OpenGL function usage in opengl_make_render_target
2017-10-30 15:23:22 -06:00
Fabian Woltermann dee0cf600f Merge pull request #1499 from asarium/fix/linuxNightlyBuilds
Fix dependency issues when building libcurl for FTP deploy
2017-10-30 13:55:35 +01:00
asarium 6181c0b2f7 Fix dependency issues when building libcurl for FTP deploy 2017-10-29 11:20:39 +01:00
z64555 0f942afaae Simplify out-of-frame calls.
*Homing conditions are now consistant with in-frame checks
*Swarm missiles will now only change their homing pos during a change frame. This'll reduce their hit rate if SWARM_FRAME_STOP_SWARMING is too low, but will make their pathing more cinematic.
2017-10-22 14:42:33 -05:00
z64555 cdde87662a Refactors swarm_update_direction() a bit for readability and consistency.
* Changed stop distance to a stop frame. Frame was chosen instead of distance or time to ensure missiles won't appear to jerk twice in succession.
2017-10-22 02:00:01 -05:00
m!m 4e7f8fa92a Merge pull request #1496 from MageKing17/bugfix/music-parse-assertion
Fix misused assertion in music table parsing code.
2017-10-21 19:47:22 +02:00
MageKing17 867ebfed89 Fix misused assertion in music table parsing code.
The condition of an assertion doesn't exist in a release build, and assertions should never be used for bad data anyway.
2017-10-21 09:56:12 -07:00
asarium 0ff8a2c159 Add support for multiple sounds in one game sound entry
This adds support for specifying multiple sounds for a single game sound
entry. The engine then selects which sound will be played based on the
strategy provided by the game data. This required a few changes to some
of the game code since previously every game sound had exactly one sound
file attached to it. The most notable change is that it is no longer
possible to determine the exact duration a sound can have so instead the
new code computes the maximum duration a sound can have and uses that
where appropriate.

This also adds support for randomizing the pitch and volume of the sound
to provide a more varied experience even if only a single sound is used.

One possible issue that exists is that the "sequential" strategy only
works globally at the moment so if two sources use the same game sound
concurrently then the two sources will share the sequence of sounds
since there is no sound instance data at the moment. That can be added
in a future change but should not present a huge issue for most
use-cases.

Visual Studio on Appveyor somehow causes deprecation error on _our_
definition of vsprintf. I have no idea why these changes introduced this
warning but I won't debug Visual Studio compiler bugs that I can't
reproduce with my Visual Studio version so I just disabled those
warnings.
2017-10-17 10:57:22 +02:00
asarium 8272304cfa Remove global Snds and Snds_iface vector 2017-10-17 10:30:00 +02:00
asarium 0522566790 Replace direct usages of Snds vector with a function call
This will make it easier to validate the used handles and is generally
better since it doesn't require a global sounds vector.
2017-10-09 15:02:29 +02:00
MageKing17 59e7b10b73 Merge pull request #1494 from asarium/fix/ballisticSoundOutOfRange
Fix out-of-range vector access in ballistic sound code
2017-10-06 16:19:47 -07:00
asarium eb4cfeb256 Fix out-of-range vector access in ballistic sound code
The code probably tried to check if the sound is available but since the
sounds vector is not long enough if the sound is not specified in the
table it would cause an out-of-bounds failure if the sound was missing
from the table. Furthermore, the current code would only have worked if
the sound was preloaded since the id is -1 until the sound is loaded for
the first time.
2017-10-06 19:51:26 +02:00
asarium a7b1c00a84 Fix handling of relative source directions
Previously, the source orientation was always aligned to the world so it
couldn't adapt to a weapon that changes direction. This fixes that by
introducing a "relative" mode for source orientations that is enabled by
default and disabled if the direction is set explicitly.
2017-10-04 15:59:09 +02:00
asarium e484a84d97 Fix several oversights and bugs in the particle effect code
The particle sources of the beams were missing multiple properties
(direction and impact normals) and the generic shape effect didn't have
any way of controlling how long the source was active. This fixes that
by introducing an effect timing field similar to the single particle
effect.
2017-10-04 10:51:35 +02:00
MageKing17 bd2bb12ad3 Merge pull request #1492 from MageKing17/bugfix/shield-impact-sounds
Make shield impact sounds more intuitive.
2017-10-03 12:00:49 -07:00
MageKing17 c890c0af1f Make shield impact sounds more intuitive.
Shield impact sounds now re-use the shield quadrant calculated by the collision code instead of naively recalculating based on global hitpos, allowing the hull impact sound to play if the shot pierces shields or was fired from within the shield mesh, and simplifying the relevant calculations in the process.
2017-10-03 09:06:34 -07:00
m!m 9cda43afb2 Merge pull request #1491 from ashdnazg/mingw_fix_include
Add include <cinttypes> (fix mingw build)
2017-10-03 11:50:44 +02:00
Eshed 34b4321416 add include
required by PRIu64
2017-10-03 11:32:56 +03:00
asarium 3a18a88e30 Fix OpenGL function usage in opengl_make_render_target
The function previously used glFramebufferTexture3D which caused issues
on the Mesa drivers and probably also with other drivers. This fixes
that by using glFramebufferTextureLayer which is the right function for
this use case.
2017-09-26 14:10:56 +02:00
asarium 686bf15879 Ensure that init_render is called before rendering the scene
This was previously not enforced and some code did not call this
function at the correct time which caused crashes since data was not
initialized correctly. This adds a check to ensure that the function was
called and fixes the code that uses the model_draw_list.
2017-09-24 15:53:14 +02:00
asarium 22f0ba89a4 Use a C-struct for managing GPU model data layout
In previous versions of FSO the GPU data of a model was stored in
various different layouts depending on what data was required for
rendering that model. Since the transform batching code was added to the
model loading code this wasn't the case anymore since all data had to
use the same vertex stride even if the data wasn't used.

This made these changes possible where a standard C-struct is now used
for managing the layout of the data in GPU memory. This makes the code
easier to read and also easier to extend in the future since all layout
data is available in the struct.
2017-09-20 17:39:31 +02:00
Fabian Woltermann a3bf47991b Merge pull request #1485 from asarium/fix/1483
Ensure that viewport setting calls are valid
2017-09-16 19:27:13 +02:00
asarium 6af1768147 Ensure that viewport setting calls are valid
This fixes a CTD when FRED is started since the graphics function
pointers are not valid at that point which causes a null pointer
dereference when starting FRED. This fixes that by checking if the
graphics system has been initialized before calling that function.

This fixes #1483.
2017-09-16 18:24:13 +02:00
asarium 0d9fbd4725 Use SCP_strings and SCP_vectors in SEXP code
I split this from #1331 to make reviewing these two changesets easier.

These changes convert all usages of const char* to SCP_string in the
static SEXP arrays so that the dynamic SEXP system can use SCP_strings
instead of having to allocate the strings and then somehow figure out
which strings must be freed at the end of the program.

This also converts the SEXP arrays to vectors so that new SEXP operators
can be added at runtime later.
2017-09-14 11:11:52 +02:00
asarium c6975fda3c Use uniform buffer blocks for passing uniform data to shaders
This uses UBOs for building a buffer object of uniform data before
using that data to draw objects. This should reduce the CPU overhead by
reducing the amount of glUniform calls required for executing a single
draw call. This is especially useful if rendering is limited by the CPU
which should help performance for people with slower CPUs.

This fixes #910.
2017-09-13 11:54:16 +02:00
Fabian Woltermann 52baa1f115 Merge pull request #1480 from asarium/fix/movieScaling
Restore 2D matrix setting behavior
2017-09-12 12:19:39 +02:00
asarium d684dcea1b Restore 2D matrix setting behavior
This restores the behavior from before the matrix system changes. The
observed behavior is more or less the desired behavior sinde setting the
2D projection matrix resets the model matrix stack but it happens to
work with the previous movie code since the 2D matrix is not set if no
perspective projection matrix was set before. This would need to be
fixed if the movie player should ever work within a mission but for now
this will fix the reported bug.
2017-09-12 11:35:11 +02:00
Fabian Woltermann fa7f49f1e4 Merge pull request #1478 from asarium/opengl/externalLightManagment
Move light handling out of OpenGL code
2017-09-10 14:33:53 +02:00
Fabian Woltermann cc3dc5f566 Merge pull request #1476 from asarium/feature/pngScreenshots
Use PNG instead of TGA for saving screenshots
2017-09-10 14:33:27 +02:00
Fabian Woltermann 19c50412ba Merge pull request #1477 from asarium/opengl/gsInstancing
Use geometry shader instancing for shadow map rendering
2017-09-10 14:33:07 +02:00
asarium cdd391caa8 Move light handling out of OpenGL code
There is nothing specific to OpenGL in that code anymore since it's all
handled in the shaders at this point. This will make the lighting
information available in the normal graphics code which allows to use
those values when filling the uniform buffer for the model rendering.
2017-09-10 11:48:38 +02:00
asarium 4860f72678 Use geometry shader instancing for shadow map rendering
This provides ~10% to 20% of an improvement if shadows are enabled. The
required features are not available in our OpenGL target version so I
added a fallback meachanism that will continue to use the standard
instancing method.

With an RX 480 and these changes I can play/watch the BP2 Icarus
cutscene at a consistent 60FPS which wasn't possible before.
2017-09-09 21:14:25 +02:00
Fabian Woltermann 5ba33228cb Merge pull request #1473 from asarium/fix/1472
Only use 16 bit-per-pixel for PCX data loading
2017-09-09 20:48:18 +02:00
Fabian Woltermann b7f3fdbb98 Merge pull request #1471 from asarium/fix/unsupportedShadowFramebuffer
Add proper fallback path for unsupported shadow framebuffer
2017-09-09 20:47:38 +02:00
Fabian Woltermann 1bffdce6ef Merge pull request #1474 from asarium/opengl/externalMatrixStack
Move graphics matrix handling out of OpenGL code
2017-09-09 20:46:19 +02:00
asarium b130d526ff Use PNG instead of TGA for saving screenshots
This was requested by Axem for improving the usability of FSO
screenshots. This will remove the need to convert the TGA files to PNG
before uploading them to an online image hoster.
2017-09-09 18:28:55 +02:00
asarium 4c1ed2f66a Move graphics matrix handling out of OpenGL code
All transformations are now handled by shaders so there is nothing
special going on in the graphics API specific code anymore. Since model
uniform buffers require access to these matrices I moved the matrix
handling out of the graphics API code.
2017-09-05 12:36:32 +02:00
asarium d30a73a578 Only use 16 bit-per-pixel for PCX data loading
The PCX loader requires this or else the data isn't loaded correctly.
This matches what the code did before the texture array merge but it
only does it for PCX textures now since the other formats handle 32 and
24 bits per pixel correctly.

This fixes #1472.
2017-09-04 13:11:04 +02:00
Fabian Woltermann fa03117eaf Merge pull request #1323 from asarium/opengl/uniformBuffers
Use a uniform buffer object for storing deferred lighting data
2017-09-04 12:32:12 +02:00
asarium 2eb109dc49 Add proper fallback path for unsupported shadow framebuffer
If a 32-bit color shadow framebuffer is not supported this will first
try to fall back to 16-bit and if that still doesn't work it will
disable shadows completely. This should fix the rendering artifacts
reported on the forums here:
http://www.hard-light.net/forums/index.php?topic=93867.msg1854164#msg1854164
2017-09-04 12:02:49 +02:00
asarium bef57f7559 Fix error line reported by Lua Errors
This adds empty lines to the beginning of the Lua source passed to the
interpreter so that the interpreter sees the lines in the source as they
appear in the table.

This might slow down parsing a bit since get_line_num is quite slow but
it should not be noticable in most instances since the script tables
tend to be quite short.

This fixes #1469.
2017-09-04 10:56:39 +02:00
asarium b807c670db Use unsynchronized buffer mapping for updating uniform buffer
Since the system already tracks if a buffer is still in use by the GPU
the buffer updates can assume that there will be no synchronization
issues if the buffer is mapped into memory.
2017-09-03 12:40:33 +02:00
asarium 24b71441c0 Add debug scope to uniform buffer retiring function 2017-09-03 12:40:33 +02:00
asarium e47581ffa5 Add documentation to new classes 2017-09-03 12:40:33 +02:00
asarium c585314ff1 Use a uniform buffer object for storing deferred lighting data
This converts the deferred lighting shader to use uniform buffers for
the dynamic data sent to the GPU while rendering the lighting effects.
This doesn't affect performance but the deferred lighting code is a
nicely isolated piece of rendering code where I could test how the
rendering code could use the uniform buffers.

This is related to #910.
2017-09-03 12:40:33 +02:00
MageKing17 97d09ae6ad Merge pull request #1468 from asarium/cleanup/noStandaloneClippingPlanes
Remove graphics functions for explicit clipping planes
2017-09-02 08:44:30 -07:00
asarium 250bf919a7 Remove graphics functions for explicit clipping planes
The function implementations were empty anyway and the code that called
them wasn't used anymore.
2017-09-02 13:20:41 +02:00
MageKing17 f8dd06ccef Merge pull request #1467 from Goober5000/medal_button_hotspot
add field for setting the hotspot index of the exit button in the medals screen
2017-09-01 11:27:11 -07:00
Fabian Woltermann 67416cc8f6 Merge pull request #1447 from asarium/opengl/useExtensions
Only generate headers for OpenGL 3.2
2017-09-01 17:01:46 +02:00
Fabian Woltermann 7118697a35 Merge pull request #1454 from asarium/opengl/noImmediateDraws
Move immediate mode rendering into generic graphics code
2017-09-01 17:00:06 +02:00
Fabian Woltermann 095c1ebe2b Merge pull request #1458 from Goober5000/time_docked_fixes
several fixes to time-docked and time-undocked
2017-09-01 16:58:00 +02:00
Fabian Woltermann 8c89c19c7e Merge pull request #1155 from asarium/feature/debugWindowScrolling
Add scrolling support to new debug window
2017-09-01 16:37:10 +02:00
m!m ae3d06c54f Merge pull request #1328 from chief1983/libupgrade/sdl2_0_5
Upgrade included libSDL2 to 2.0.5
2017-09-01 15:04:54 +02:00
Cliff dbbb8af17b Avoid a potential crash when ff is enabled without a joystick. 2017-08-31 20:38:40 -05:00
Cliff Gordon a23830359a libupgrade/sdl2_0_5: joy_get_device is not defined, use this instead, thanks @ashdnazg 2017-08-31 19:56:15 -05:00
Cliff Gordon 31e572ec03 Revert "Allow force feedback to work again."
This reverts commit 19b5ee97f7.
2017-08-31 19:56:15 -05:00
Cliff Gordon 29b5c4bf7a libupgrade/sdl2_0_5: Attempt to migrate the MinGW support to the official libs using the filename they are published with. 2017-08-31 19:56:15 -05:00
Cliff Gordon 3811270a09 libupgrade/sdl2_0_5: Upgrade to SDL 2.0.5. 2017-08-31 19:56:15 -05:00
Cliff Gordon 64fc95ec8c libupgrade/sdl2_0_5: Remove old build system files from gitignore. 2017-08-31 19:56:15 -05:00
MageKing17 0c70672a84 Merge pull request #1461 from Goober5000/fix_emp_time_for_capship_turrets
make "same emp time for capships" actually work
2017-08-31 07:00:47 -07:00
Goober5000 67e6bcca9f make "same emp time for capships" actually work
Back when I added the "same emp time for capships" flag in SVN r9540, I neglected to multiply the EMP time by 1000, as the EMP disruption time for fighters is specified in seconds but the time for capships is specified in milliseconds.  So, using this flag would cause capships to suffer EMP disruption for almost no time at all.

This PR fixes that, and also extends the explosion-effect sexp to specify this parameter.  And I also cleaned up the fireball section by calling eval_num(n) just once instead of several times.
2017-08-31 04:16:15 -04:00
m!m 8de33ab56a Merge pull request #1464 from Goober5000/boolify_is_sexp_true
change is_sexp_true return type from int to bool
2017-08-31 10:06:47 +02:00
Goober5000 b786b8e230 fix another mismatch 2017-08-31 02:10:01 -04:00
Goober5000 9dc308331b fix some warnings I missed earlier 2017-08-30 16:03:15 -04:00
Goober5000 628ac86c3e Merge pull request #1465 from asarium/feature/dynamicTstrings
Looks good to me.
2017-08-30 12:23:20 -04:00
asarium dcee8a302e Remove limit for tstring table entries
Since 4500 strings are not enough for some mods there was a request for
removing that limit. I chose to use an unordered map for storing the
entries since the indices are not guaranteed to be sequential.

This fixes Mantis 3199.
2017-08-30 13:04:24 +02:00
Goober5000 c7673f0591 swap order of parameters to avoid short-circuiting 2017-08-29 20:25:04 -04:00
Goober5000 000d0c3a0d change |= and &= to be the more verbose and correct logical operators 2017-08-29 14:11:35 -04:00
Goober5000 ec19f9be98 change is_sexp_true return type from int to bool 2017-08-29 13:50:22 -04:00
Goober5000 3005a67573 Merge pull request #1459 from Goober5000/string_concatenate_block
add string-concatenate-block sexp
2017-08-29 13:49:18 -04:00
Goober5000 33d4a7efa7 more fiddling with string format arguments 2017-08-29 12:30:16 -04:00
MageKing17 6c4e03d9dc Merge pull request #1462 from Goober5000/fix_sexp_error_reporting
fix Assertion in sexp error reporting
2017-08-29 06:32:49 -07:00
m!m 537ee433de Merge pull request #1463 from Goober5000/fix_sound_coordinates
fix negative coordinates in play-sound-from-x
2017-08-29 09:54:20 +02:00
Goober5000 2cff45f2c5 fix negative coordinates in play-sound-from-x
When the OPF_NUMBER and OPF_POSITIVE behaviors were made more robust, it exposed a latent bug in the play-sound sexps.  These had OPF_POSITIVE where they should have had OPF_NUMBER.  With this fix, sounds can now play from all coordinates, positive or negative.
2017-08-28 19:12:40 -04:00
Goober5000 466e4c159f use SIZE_T_ARG 2017-08-28 18:39:01 -04:00
Goober5000 6c7de5120e improve warning messages per feedback 2017-08-28 14:40:44 -04:00
Goober5000 b2b0ba3630 to be pedantic, this happens at the very end of error-reporting mode 2017-08-28 14:26:34 -04:00
Goober5000 14dcff6f5f might as well restrict the test to only running during error-check mode 2017-08-28 14:23:53 -04:00
Goober5000 d826537485 fix Assertion in sexp error reporting
There is a bug where, when displaying an error message with a sexp node that contains a variable, the code will trigger an Assertion in the process of printing the error message.  This is because it tries to transcode the sexp variable from name to index, when that has already been done further up the pipeline.  This fixes that by adding a quick test to see if the expected variable name is an integer.
2017-08-28 14:17:02 -04:00
Cliff Gordon 95c0fad96f Merge pull request #1460 from asarium/fix/openglErrors
Readd accidentally removed OpenGL calls
2017-08-28 10:35:07 -05:00
MageKing17 85b3a30376 Merge pull request #1456 from Goober5000/is_docked_sexp
add is-docked sexp
2017-08-28 08:09:13 -07:00
asarium 3c347ae938 Readd accidentally removed OpenGL calls
I changed those lines in another PR and forgot to revert these before I
submitted it. This will fix the OpenGL errors that appeared when shadows
were enabled.
2017-08-28 16:53:50 +02:00
Fabian Woltermann 09b28f2219 Merge pull request #1453 from asarium/opengl/noRedundantActiveTexture
Avoid redundant glActiveTexture calls
2017-08-28 09:00:56 +02:00
Fabian Woltermann 3c0eec27de Merge pull request #1432 from asarium/qtfred2_/dev
Add most of the remaining menu action implementations
2017-08-28 08:59:41 +02:00
Fabian Woltermann 2fb078f32b Merge pull request #1455 from asarium/fix/deleteUnusedFile
Delete unused OpenGL video presenter
2017-08-28 08:57:26 +02:00
Goober5000 a19b3030b6 enhance warning messages 2017-08-27 18:01:14 -04:00
Goober5000 5095b1c57a several fixes to time-docked and time-undocked
Time-undocked will cause FSO to freeze unless you know what you're doing, so this PR fixes some gotcha areas.  Inspired by The E's rant on Discord which, while not 100% correct, did indicate some areas for improvement.

1) Set the default "number of times docked" argument to 1 when the sexp is created in FRED, same as with the has-[un]docked-delay sexps
2) Catch any <= 0 counts when the sexp is called in FRED and set them to 1.  (This was done for other sexps which used mission_log_get_time_indexed, but was not done for time-[un]docked for some reason.)
3) Add an assertion to mission_log_get_time_indexed as a last resort to guard against invalid counts.
2017-08-27 17:18:39 -04:00
Goober5000 ab14742f96 add is-docked sexp 2017-08-27 16:24:04 -04:00
asarium 492c4ba10a Delete unused OpenGL video presenter
The deletion of this file was missed in the cutscene changes.
2017-08-27 18:12:01 +02:00
asarium 999eb8a3f9 Add documentation to new functions 2017-08-27 17:32:58 +02:00
asarium 03aa75c39a Move immediate mode rendering into generic graphics code
Since this code is the same for all possible graphics backends it can be
moved outside the OpenGL implementation to simplify that code.
2017-08-27 17:14:02 +02:00
asarium 4f096c26b2 Avoid redundant glActiveTexture calls
This introduces a new function in the OpenGL state tracker which
combines setting the active texture unit and enabling a texture. The
reason this is a good idea is that this new function can filter out
unneeded calls to glActiveTexture if the texture is already enabled on
that specific unit. This happens very often when rendering several
submodels of a model which share their textures.

This is unlikely to yield significant performance improvements but
avoiding unneded OpenGL calls is always a good idea.
2017-08-27 13:46:44 +02:00
Goober5000 3db9fe9383 add field for setting the hotspot index of the exit button in the medals screen 2017-08-26 13:35:38 -04:00
Fabian Woltermann d1e236451f Merge pull request #1452 from asarium/fix/tgaLocking
Fix memory allocation in tga loading code
2017-08-26 18:11:11 +02:00
m!m 6cf7cb0843 Merge pull request #1450 from Goober5000/mantis_3174_fix
toss out the campaign savefile if we are restarting a previously finished campaign
2017-08-26 18:10:29 +02:00
asarium 2084eb01e8 Fix memory allocation in tga loading code
The code did not use the right method for calculating the required size
of the memory. This was never noticed before because the old OpenGL
texture loading code only used 16-bit textures for interface data but
the new code uses 32-bit textures which exhausted the available memory.

This was found and reported by @chief1983.
2017-08-26 17:08:26 +02:00
Goober5000 7d1365800f clean up old comments 2017-08-26 03:43:26 -04:00
Goober5000 66ce0acc17 toss out the campaign savefile if we are restarting a previously finished campaign 2017-08-26 03:38:20 -04:00
Fabian Woltermann c29954d672 Merge pull request #1449 from asarium/fix/arrayDetectionBug
Fix bug in texture array detection code
2017-08-25 19:55:49 +02:00
asarium f2d5246ccb Fix bug in texture array detection code
The code would have displayed the warning but didn't actually set the
flag to let the rest of the code know.
2017-08-25 18:22:34 +02:00
asarium b6dcc4f5ef Only generate headers for OpenGL 3.2
Since our target version is only OpenGL 3.2 all additional functionality
should only be used through their respective extensions to avoid
accidentially using a function not available in our minimum target
environment.
2017-08-25 18:18:17 +02:00
Fabian Woltermann bd62ceeeb0 Merge pull request #1318 from asarium/opengl/textureArrays
Use OpenGL texture arrays for animations
2017-08-25 18:00:56 +02:00
asarium f1bf0a411c Use OpenGL texture arrays for animations
This converts all usages of bmpman textures to OpenGL texture arrays.
That means that all frames of an animation are stored in a single OpenGL
texture object and can be accessed at the same time in a single draw
call. This should significantly reduce the overhead of drawing lots of
particles since all particles of a single animation can be drawn with a
single draw call.

This fixes #1169.
2017-08-25 11:31:02 +02:00
asarium 28898ca8e3 Add scrolling support to new debug window 2017-08-25 09:51:09 +02:00
MageKing17 3acdf3e801 Merge pull request #1399 from asarium/fix/1306
Use unique_ptr for storing HUD gauge pointers
2017-08-24 09:23:54 -07:00
MageKing17 f1101bee5d Merge pull request #1414 from asarium/feature/targettedFSOVersion
Add mod table setting for specifying targetted FSO version
2017-08-24 09:21:58 -07:00
MageKing17 e617f0cc41 Merge pull request #1435 from asarium/fix/ffGlobalGain
Add config option for setting the FF strength
2017-08-24 09:09:55 -07:00
MageKing17 7c9f73fbdc Merge pull request #1444 from asarium/fix/travisSourceCompression
Actually compress the source archive
2017-08-24 09:09:10 -07:00
Fabian Woltermann c36b47a35c Merge pull request #1290 from asarium/opengl/simplifyGrInterface
Move 2D drawing functions to a generic implementation
2017-08-24 17:41:32 +02:00
m!m 8d0b0a76f2 Merge pull request #1446 from MageKing17/bugfix/cmeasure-timer-interval-init
Explicitly initialize cmeasure_timer_interval to 0.
2017-08-24 17:21:05 +02:00
MageKing17 36e5afe1be Explicitly initialize cmeasure_timer_interval to 0.
If we rely on uninitialized values, we're likely to wind up with countermeasures that are only ever active for a single frame.
2017-08-24 04:54:42 -07:00
m!m 20398150d8 Merge pull request #647 from MageKing17/feature/countermeasure-pulse-interval
Allow countermeasures to pulse at regular intervals instead of globally.
2017-08-24 10:38:41 +02:00
m!m e085cc20ab Merge pull request #1445 from MageKing17/bugfix/beam-sound-unpause
Actually unpause 3D beam sounds correctly.
2017-08-24 09:25:33 +02:00
asarium 6b5869853c Correctly handle alpha blending for gr_flash_alpha 2017-08-23 14:42:54 +02:00
asarium a6411cc1d3 Add documentation for drawing functions 2017-08-23 14:42:54 +02:00
asarium bd4427a832 Reformat 2017-08-23 14:42:54 +02:00
asarium 6dbd7c34e6 Clean up a few remaining functions 2017-08-23 14:42:54 +02:00
asarium 7a3029d1e3 Remove unused gr_screen API functions 2017-08-23 14:42:54 +02:00
asarium 1bca5f128d Convert curve and circle functions 2017-08-23 14:42:54 +02:00
asarium 6bbb6be880 Move line drawing functions to generic implementation 2017-08-23 14:42:54 +02:00
asarium c1c2b72ef0 Move gr_string out of OpenGL code 2017-08-23 14:42:54 +02:00
asarium 1aa85d236e Begin moving 2D functions to a generic implementation
Thanks to the new material system, it's now possible to easily make the
2D functions independent of the underlying graphics API which allows to
reduce the size of the gr_screen 2D API.
2017-08-23 14:42:54 +02:00
MageKing17 1afc5eec13 Actually unpause 3D beam sounds correctly.
beam_pause_sounds() "pauses" looping beam sounds by setting their volume to 0; beam_unpause_sounds() "unpaused" by calling beam_recalc_sounds(), which only set the volume correctly when -no_3d_sound is set; 3D sound updates the sound's position without changing its volume. This PR just makes beam_unpause_sounds() perform the inverse operation of beam_pause_sounds() if 3D sounds are enabled.
2017-08-23 05:03:25 -07:00
Fabian Woltermann 759c9b1148 Merge pull request #1439 from asarium/opengl/genericVideoDisplay
Remove OpenGL code from cutscene presenter
2017-08-23 14:02:53 +02:00
Fabian Woltermann 47bb378342 Merge pull request #1438 from asarium/fix/aabitmapRemapping
Move 4 bit color conversion out of graphics code
2017-08-23 14:02:35 +02:00
m!m 0b3dad8dc0 Merge pull request #1308 from niffiwan/feature/tint_shader
Add colour-configurable tint shader
2017-08-23 12:53:50 +02:00
m!m 13e601a523 Merge pull request #1372 from MageKing17/feature/avx2-build-support
Add AVX2 to the list of supported MSVC compiler optimizations.
2017-08-23 12:50:16 +02:00
MageKing17 5de1b684f4 Merge pull request #1442 from asarium/fix/noWarningStacktrace
Remove stack trace from warning dialogs
2017-08-23 03:46:21 -07:00
asarium c5dcaf88d8 Actually compress the source archive
The previous command simply created a tar with a tar.gz ending which is
wrong. This fixes that.
2017-08-23 12:45:47 +02:00
MageKing17 55558cc608 Merge pull request #1437 from asarium/fix/unixSources
Build Unix source package before configuring
2017-08-23 03:44:43 -07:00
MageKing17 addc3ef383 Allow countermeasures to pulse at regular intervals instead of globally.
Adds a new "+Pulse Interval:" countermeasure field that enables the new behavior; all countermeasures that don't have this field defined still use the old behavior of the global frame counter.

This changes countermeasure logic quite a bit, but I attempted to mitigate performance implications by re-using an existing traversal of the object list in order to build the list of active countermeasures each frame. If any countermeasures are actively pulsing in a frame, the object list is traversed again, looking for homing weapons. Each homing weapon then goes through the active countermeasure list and checks to see if it got decoyed. Most of this central logic is unchanged from the old behavior, although no longer separated into two functions, and it should be more efficient since it's using a prepared list of active countermeasures instead of traversing the object list looking for countermeasures for every homing missile (which are themselves found by traversing the object list).
2017-08-23 03:39:48 -07:00
MageKing17 2c1abf78d1 Merge pull request #1443 from asarium/build/versionBump
Bump development version after final release
2017-08-23 03:37:14 -07:00
asarium 77c950ccd4 Bump development version after final release 2017-08-23 09:48:36 +02:00
asarium b160184f5b Remove stack trace from warning dialogs
It serves no purpose there since it's a message specifically designed to
be seen by modders and most times the stack trace doesn't even contain
useful information since there are no debug symbols present.
2017-08-23 00:02:28 +02:00
m!m b1b197cc9a Merge pull request #1440 from ln-zookeeper/asteroid_null_vec_fix
Fix for a null vector normalization
2017-08-21 09:54:09 +02:00
Lari Nieminen 941b7298cc Fix for a null vector normalization
If the asteroid split rules were used and the asteroid speed happened to be 0 (for example if the field has an average speed of 0), the code would try to normalize a null vector. Now, a random vector is chosen in those cases.
2017-08-21 10:09:18 +03:00
asarium f8d0a9bc7d Remove most remaining OpenGL header includes 2017-08-18 17:53:23 +02:00
asarium 72fa41a284 Use the generic rendering interface for cutscenes 2017-08-18 17:53:23 +02:00
asarium 72a797f732 Move 4 bit color conversion out of graphics code
Currently, the graphics code does some color remapping on 8
bit-per-pixel textures since those textures use special 4-bit pixel
values. These changes move that conversion out of the graphics code and
into the image loading/font bitmap creation code.

The reason this is needed is because this conversion breaks 8-bit
textures that try to use the full range of colors. I need to do exactly
that for moving the cutscene renderer to our generic rendering interface
which I can't do at the moment since the existing color conversion
corrupts the video data.

I have tested this with retail data and could not find any visual
changes after applying these changes.
2017-08-16 17:20:32 +02:00
asarium 2b0ec7161a Build Unix source package before configuring
The previous version included the make files which increased the size of
the package.
2017-08-15 10:18:09 +02:00
m!m 637a9621f1 Merge pull request #1436 from Goober5000/pr_922_followup
fix typo in AI flag conversion
2017-08-14 23:41:44 +02:00
Goober5000 70c5aa88f2 then again, we should really assert on both 2017-08-11 18:05:13 -04:00
Goober5000 1857f9b928 fix typo in AI flag conversion 2017-08-11 17:53:42 -04:00
asarium 90c23c007c Add config option for setting the FF strength 2017-08-10 10:09:02 +02:00
Fabian Woltermann fb4169ba9f Merge pull request #1429 from asarium/fix/ffEffectStrength
Lower Afterburner force feedback effect strength to previous levels
2017-08-08 14:35:35 +02:00
asarium 4648721674 Add mod table parsing to qtfred initializers 2017-08-04 20:04:54 +02:00
asarium ae4a7319e5 Add About dialog 2017-08-04 15:13:16 +02:00
asarium 3c7f7f9df0 Add error checker action 2017-08-04 14:13:47 +02:00
asarium e11250f7e8 Add subsystem selection actions 2017-08-04 13:28:36 +02:00
asarium 24dec72f41 Add control object action 2017-08-04 10:55:50 +02:00
asarium 89c36b68c7 Add Align object action 2017-08-04 10:54:56 +02:00
asarium e66d9d1246 Add Level object action 2017-08-04 10:53:27 +02:00
asarium 789135516e Add Misc menu shortcuts 2017-08-04 10:53:27 +02:00
asarium 91b61d446f Add group action support 2017-08-04 10:53:27 +02:00
asarium 8e5aafb6e5 Add delete actions 2017-08-04 10:53:27 +02:00
asarium cb0080bfc1 Add actions for hiding and showing toolbar and statusbar 2017-08-04 10:53:27 +02:00
asarium a03180c46e Add Save camera position action 2017-08-04 10:53:27 +02:00
asarium a18fdd2112 Add support for hiding specific teams 2017-08-04 10:53:27 +02:00
asarium 7c81ac1d86 Improve waypoint dialog layout and behavior
The dialog is not resizable anymore and the combobox is disabled if
there are no entries.
2017-08-04 10:53:27 +02:00
asarium bc7414c403 Improve window title handling 2017-08-04 10:53:27 +02:00
asarium a7418d6dde Add documentation to runAfterInit 2017-08-04 10:53:27 +02:00
m!m f83c2e9cdc Merge pull request #1431 from asarium/qtfred2_/sync
Sync qtFRED branch
2017-08-04 10:52:53 +02:00
asarium 965a327630 Merge branch 'master' into qtfred2_/sync 2017-08-04 09:09:32 +02:00
Fabian Woltermann 1448256140 Merge pull request #1430 from asarium/fix/nightlyDeploy
Fix Travis CI nightly deploy
2017-08-03 18:02:11 +02:00
asarium 7de592bf9b Fix Travis CI nightly deploy
I have no idea why this doesn't work anymore. I didn't even touch that
line when I added the test build stuff...
2017-08-03 17:18:48 +02:00
asarium 783852a115 Lower Afterburner force feedback effect strength to previous levels
This was suggested by taylor on the forums and should match the previous
values more closely.
2017-08-03 08:55:50 +02:00
Tyler Blount c9bb3f4caa Merge pull request #1428 from asarium/qtfred2_/dev
Add ship selection dialog
2017-08-02 01:12:36 -06:00
Fabian Woltermann 84fd7123a5 Merge pull request #1420 from asarium/fix/1417
Restart spring effect after stopping all FF effects
2017-08-02 08:23:26 +02:00
asarium 3e1b020bf5 Add local rotate action 2017-07-31 13:02:56 +02:00
asarium 60d6aaccec Add orbit rotate functionality 2017-07-31 12:57:28 +02:00
asarium 18a957e8bf Fix list selection 2017-07-31 10:20:55 +02:00
asarium ad7bddfd41 Copy old mission load code to qtFRED 2017-07-30 17:50:56 +02:00
asarium a90d859891 Add object selection dialog 2017-07-30 17:37:35 +02:00
m!m ff9d06cfe1 Merge pull request #1427 from The-E/weaponloadout_fix
Fix error message for failure to load mask file in weaponloadout
2017-07-28 10:16:46 +02:00
Fabian Woltermann a158029120 When loading the mask file fails, correctly report which file we were trying to load. 2017-07-27 22:53:33 +02:00
m!m 96e8d5b66e Merge pull request #1426 from Goober5000/issue_1425_fix
for backwards compatibility, check both no-collide and no_collide
2017-07-26 15:41:47 +02:00
asarium 85fd0b0498 Restart spring effect after stopping all FF effects
SDL_HapticStopAll stops all effects, including the spring effect so the
joystick goes limp after one mission (joy_ff_stop_effects gets called at
the end of each mission).

This restarts the spring effect which should fix that issue.

This fixes #1417.
2017-07-26 11:00:50 +02:00
Fabian Woltermann 5d3e6789e6 Merge pull request #1422 from asarium/build/ciTestBuilds
Add support for building test builds on the CI servers
2017-07-26 10:59:56 +02:00
Goober5000 b8e5a395dd for backwards compatibility, check both no-collide and no_collide 2017-07-25 18:44:41 -04:00
asarium 1a1c3df379 Add support for building test builds on the CI servers
Any branch starting with "test/" will cause test builds to be compiled
and uploaded to fs2downloads. This will only work for the main
repository since the secure variables for the FTP credentials only work
for that repository.
2017-07-25 11:37:11 +02:00
Fabian Woltermann 0dc0d67c76 Merge pull request #1421 from asarium/build/releaseSources
Build a compressed package of the source as part of a release
2017-07-24 15:29:16 +02:00
asarium 0edb360fc2 Build a compressed package of the source as part of a release
This package will include the externals which are not present in the
default GitHub export.
2017-07-24 10:53:40 +02:00
Fabian Woltermann 1743e5f5d4 Merge pull request #1419 from ln-zookeeper/on_ship_arrive_wing_fix
Fixed $On Ship Arrive hooks not firing on wing arrivals
2017-07-23 17:09:21 +02:00
MageKing17 ed3f07284d Merge pull request #1418 from The-E/shader_normal_fix
Fix bug in normal map rendering
2017-07-23 06:07:55 -07:00
Fabian Woltermann c1b222ffd5 Old calculation apparently correct, just needs clamping applied. 2017-07-22 20:25:52 +02:00
Fabian Woltermann 3503b9214b Remove unnecessary punctuation 2017-07-21 20:06:53 +02:00
Lari Nieminen aff8cc8095 Fixed $On Ship Arrive hooks not firing on wing arrivals 2017-07-20 16:13:20 +03:00
Fabian Woltermann 884581a836 Reapply the fix from https://github.com/scp-fs2open/fs2open.github.com/commit/8e0304a5 2017-07-20 12:20:44 +02:00
asarium 841872aae0 Add mod table setting for specifying targetted FSO version
This adds a small system for letting a mod specify which version of FSO
was designed for. That would allow us to introduce code which would
normally break backwards-compatibility by putting it in an if block
which checks if the mod supports the FSO version which ontroduced the
behavioral change.

There is currently no code which uses the new functions yet so I added a
few tests to verify that the options do what they are designed to do.

This fixes #1389.
2017-07-14 20:09:29 +02:00
Fabian Woltermann 98af9dd903 Merge pull request #1404 from Goober5000/debug_sexp_tweak
minor enhancements to the debug sexp
2017-07-13 18:05:34 +02:00
m!m ea37b3cb17 Merge pull request #1411 from Goober5000/issue_1400_followup
use IS_VEC_NULL for floating point safety, plus a few minor touchups
2017-07-11 14:45:03 +02:00
m!m 9b1e9600ce Merge pull request #1410 from asarium/qtfred2_/dev
Add form and disband wing actions
2017-07-10 09:44:25 +02:00
Fabian Woltermann 3035a868ab Merge pull request #1401 from asarium/fix/ttfSpecialCharacters
Correctly apply scaling to TTF rendered strings
2017-07-09 20:48:12 +02:00
Goober5000 a88c50b6f2 per comments, allow variable replacement in plain strings as well 2017-07-09 14:31:36 -04:00
Goober5000 ac24ca9fd3 use IS_VEC_NULL for floating point safety, plus a few minor touchups 2017-07-09 14:11:42 -04:00
asarium 07a806e01f Clear mission on load 2017-07-09 13:25:38 +02:00
asarium ccd33eb50f Add zoom toolbar actions 2017-07-09 13:23:53 +02:00
asarium 1805c77f7c Add disband wing action and update enabled status 2017-07-09 12:46:26 +02:00
MageKing17 d085951767 Merge pull request #1400 from asarium/fix/fredInvalidIndex
Fix invalid indexing in object orientation editor
2017-07-09 03:42:04 -07:00
MageKing17 c3f19631ce Merge pull request #1402 from asarium/fix/profilingAssert
Discard non-main thread events for the frame profiler
2017-07-09 03:41:10 -07:00
m!m ca9eff3bc5 Merge pull request #1405 from MageKing17/bugfix/ani-unloading
Fix unloading streaming ANI files.
2017-07-09 12:36:55 +02:00
MageKing17 0a19616bc9 Correct inconsistency in anim_load() regarding memory-mapped files.
In commit 735f5e199b randomtiger changed how anim_load() worked in seemingly-bizarre ways, for reasons unclear to me. In brief, a condition's logic was reversed, a three-value enum was created of which only one value was used, and as a result loose files passed to anim_load() (and only loose files) would be opened as "memory-mapped", one consequence of which is that they'd keep a cfile block open until the corresponding call to anim_free() (which means that, if a mission had enough different loose animations, the cfile block limit could be reached). Since files in packfiles behaved the same way they always had (namely, being loaded into memory and then closed, thereby not taking up a cfile block), apparently nobody noticed the difference, and this inconsistent code has stayed for the past 13-and-a-half years.

This commit changes the condition after the one changed in the older commit so that they both match, then changes the enum so that the seemingly-meaningless third value is removed, and the other two values are swapped (and the default value of the file_mapped parameter to anim_load() changed) so that the original Volition behavior is restored.
2017-07-09 02:39:40 -07:00
asarium 481ebec316 Add form wing action
This also introduces the new generic dialog system which should allow
the mission code to open specific dialogs without depending on the
actual Qt implementation.
2017-07-09 10:25:06 +02:00
m!m 99d8b19ee8 Merge pull request #1408 from TRBlount/qtfred2_dialogs
Add Mission Specs Editor
2017-07-08 11:12:35 +02:00
TRBlount 5adc3216df Fix CI compilation on Linux and Windows Debug 2017-07-08 02:21:18 -06:00
TRBlount 55f39e088d Use Dialog Provider and fix some model functions 2017-07-08 02:04:36 -06:00
TRBlount 71b572b7f4 Fix CI issues 2017-07-07 17:58:18 -06:00
TRBlount c1908669d9 Finish Custom Wing Name Editor 2017-07-07 16:31:29 -06:00
m!m 255e9aa21e Merge pull request #1406 from asarium/build/nightlySFTP
Fix SFTP path and mac upload
2017-07-07 23:31:09 +02:00
TRBlount a9d25fd18d Add Custom Wing Model 2017-07-07 14:37:00 -06:00
TRBlount 72c5d17739 Add Custom Wing dialog 2017-07-07 13:59:53 -06:00
asarium 550f459747 Fix SFTP path and mac upload 2017-07-07 18:03:07 +02:00
TRBlount ecf10d8227 Fix comments and add Command Messages 2017-07-07 04:18:11 -06:00
TRBlount 8ab448dd70 Move to modification system
Alerts the user whenever they have unsaved changes
2017-07-07 03:16:21 -06:00
TRBlount ea53cff723 Add Mission Spec Model 2017-07-07 02:37:58 -06:00
MageKing17 6da72bb1a0 Fix inverted order of unloading streaming ANI files.
When streaming an ANI file, first anim_load() is called, then init_anim_instance(). The latter increments the animation's instance_count. If anim_free() is called on an animation that still has instances, it refuses to free the animation. generic_anim_unload() first called anim_free(), then free_anim_instance().

The fact that ANI files would ever unload at all seems to be because some code would unload twice. I can only assume that, combined with the fact that the bug only applies to ANI files, explains how this bug went undetected since November of 2009 (commit b43417882f seems to be when it was added, from a quick glance at git blame).
2017-07-07 01:23:20 -07:00
MageKing17 c7fbefeb58 Remove potentially-harmful condition in message_mission_free_avi()
If we tell it to free up the animation, I think it should happen regardless of whether or not the HUD_TALKING_HEAD gauge is currently active or not. Also, unloading an animation shouldn't crash even if one wasn't loaded in the first place... and if it does, we should probably fix that instead of slapping a band-aid on the calling function.
2017-07-07 01:18:09 -07:00
Goober5000 98e316bca6 minor enhancements to the debug sexp 2017-07-07 01:25:54 -04:00
Cliff Gordon 78a1e5baab Merge pull request #1403 from asarium/build/nightlySFTP
Compile curl with SSH support for nightly deploy
2017-07-06 15:17:48 -05:00
asarium 080ce8419a Compile curl with SSH support for nightly deploy 2017-07-06 17:58:48 +02:00
asarium 06e9248079 Discard non-main thread events for the frame profiler
The old code is not able to handle multi-threaded events so this change
simply filters out all the events that originated from another thread.

This fixes an Assertion caused by an invalid event.
2017-07-06 10:10:52 +02:00
TRBlount 407888641c Modify UI to use correct components
Some misuse of Spin Boxes and Line Edits
2017-07-05 18:40:36 -06:00
asarium e04c60ed6f Align special characters to the base line of the rendered string 2017-07-05 18:13:45 +02:00
TRBlount ac554f24c2 Fix include formatting and Combo Box issues 2017-07-05 02:27:42 -06:00
TRBlount 56670b2ed7 Figure out QFileDialogs, issues with AI Profile Box 2017-07-05 02:19:16 -06:00
asarium 81d9ca8e4a Correctly apply scaling to TTF rendered strings
This fixes weird misplaced special characters since the TTF strings
weren't rendered at the right position. This should fix that.

This fixes an issue reported on the forums by Novachen.
2017-07-05 09:09:38 +02:00
TRBlount 7e26955853 Figure out text cursors 2017-07-04 19:30:54 -06:00
TRBlount c085eef9a0 Update UI file and setup mission flags 2017-07-04 02:15:14 -06:00
asarium bf2ca61e5a Fix invalid indexing in object orientation editor
This could happen if the user enabled "Point to" and selected "Object"
without having an object selected. This can only happen when there is
only one object in the mission so it's only a minor bug but still
something worth fixing.
2017-07-03 20:11:06 +02:00
TRBlount 8061125d84 Continue implementation
Some data actually saves now
2017-07-03 08:21:48 -06:00
asarium 72013d4c31 Use unique_ptr for storing HUD gauge pointers
The previous system used naked pointers which probably worked fine but
this should give us some extra memory-leak security.
2017-07-03 12:52:39 +02:00
TRBlount 93b1c0df17 Get dialog to close on accepted and rejected 2017-07-03 00:55:31 -06:00
TRBlount 41f889e55d Add Mission Spec Editor and begin implementation 2017-07-02 17:46:00 -06:00
Goober5000 416d45d060 deprecate string-concatenate since it's now redundant 2017-07-01 23:05:48 -04:00
Goober5000 18be4e854c add string-concatenate-block, which is a better design than the original string-concatenate 2017-07-01 23:05:48 -04:00
Tyler Blount 7d92178777 Merge pull request #1398 from asarium/qtfred2_/dev
Add object orientation editor
2017-07-01 16:54:35 -06:00
asarium ac69bd5712 Remove dialog test code 2017-07-01 23:47:15 +02:00
asarium d6b6ea715a Add Object orientation and location editor 2017-07-01 23:42:04 +02:00
Fabian Woltermann ffe647be79 Merge pull request #1393 from asarium/build/gitHubPrebuilts
Use GitHub prebuilt URL
2017-07-01 14:09:02 +02:00
Fabian Woltermann fff2e6d1fc Merge pull request #1394 from Goober5000/issue_1381_followup
Use the already-determined sexp argument type
2017-07-01 14:08:22 +02:00
Fabian Woltermann 23e46ae7c4 Merge pull request #1395 from Goober5000/issue_1256_followup
Better handling of positive/negative discrepancy as well as finding sexp node arguments
2017-07-01 14:07:57 +02:00
MageKing17 74d270270e Merge pull request #1397 from ngld/fix_shockwave_load
Fix "Error: Can't open model file <shockwave.pof>" on second mission load
2017-06-29 14:36:00 -07:00
ngld df69d195fe Fix "Error: Can't open model file <shockwave.pof>" on second mission load 2017-06-29 21:10:56 +02:00
asarium 8c59b06b59 Add form for object orientation editor 2017-06-29 08:57:13 +02:00
Goober5000 6c871ac339 better handling of positive/negative discrepancy as well as finding sexp node arguments 2017-06-29 01:56:55 -04:00
Goober5000 24afebb808 instead of manually checking the sexp operator and argument number, just use the already-determined argument type 2017-06-28 19:10:14 -04:00
Tyler Blount e59d31d66e Merge pull request #1392 from asarium/qtfred2_/dev
Add waypoint editor
2017-06-28 01:28:31 -06:00
asarium 19c01563ca Add missing files 2017-06-28 08:52:28 +02:00
asarium 80f1f50582 Add edit popup menu and double click handling 2017-06-27 23:47:36 +02:00
asarium a057e111ba Add fully working waypoint editor
This is the first editor that is functional and uses.
2017-06-27 23:44:43 +02:00
asarium b45998b58d Add waypoint editor dialog form 2017-06-27 23:35:55 +02:00
Fabian Woltermann 6aac8c7bde Merge pull request #1391 from asarium/fix/specialCharacterFontAssertion
Fix Assertion when default Volition font could not be found
2017-06-27 16:00:11 +02:00
asarium a2da77e14c Fix Assertion when default Volition font could not be found
Instead, this will now cause a Warning when the issue is detected while
parsing the table and an Error when it still occurs at runtime.
2017-06-27 11:56:20 +02:00
Fabian Woltermann 7ca6b679b7 Merge pull request #1390 from asarium/fix/luaWhitespace
Ignore leading whitespace for gr.drawString
2017-06-27 09:36:46 +02:00
asarium 3d6bbb0b9b Ignore leading whitespace for gr.drawString
This was reported by @AxemP who wanted to have leading tabs in a text
line. However, split_str removed those characters by default since it
ignores leading whitespace. To fix that unexpected behavior of
gr.drawString I added a new paramter to split_str which disabled
whitespace removal and enabled that flag for the scripting function.

That should not be a problem for existing scripts since the expected
behavior would be that leading whitespace remains in place and since we
have not received any bug reports about missing white space I'm going to
assume that no one has used the function like this before removed those
characters by default since it ignores leading whitespace. To fix that
unexpected behavior of gr.drawString I added a new paramter to split_str
which disabled whitespace removal and enabled that flag for the
scripting function.

That should not be a problem for existing scripts since the expected
behavior would be that leading whitespace remains in place and since we
have not received any bug reports about missing white space I'm going to
assume that no one has used the function like this before.
2017-06-25 17:19:40 +02:00
asarium a912956601 Use GitHub prebuilt URL 2017-06-24 13:33:09 +02:00
m!m a769a7ef87 Merge pull request #1388 from Goober5000/sexp_targeted_fix
fix an old Volition bug in the targeted sexp
2017-06-24 09:20:43 +02:00
m!m 991e09006e Merge pull request #1387 from Goober5000/small_error_msg_fix
Small improvement in error messages in stuff_int_list and mark_int_list
2017-06-24 09:17:01 +02:00
Goober5000 3e6c3f6f62 this actually affects subsystems too 2017-06-24 01:05:08 -04:00
Goober5000 2ee3dd70ea fix an old Volition bug in the targeted sexp 2017-06-24 00:56:25 -04:00
Goober5000 c259dfb9cd improve error messages 2017-06-23 23:32:57 -04:00
m!m 2947c7972d Merge pull request #1386 from MageKing17/bugfix/opengl-framebuffer-warning
Get rid of OpenGL warnings about the framebuffer being unsupported.
2017-06-22 08:44:39 +02:00
MageKing17 eda8c65b58 Get rid of OpenGL warnings about the framebuffer being unsupported.
At least on NVidia drivers, the medium-severity warning "Framebuffer unsupported. Framebuffer object Scene framebuffer is unsupported because the depth and stencil attachments are mismatched." would get repeatedly output to the debug log. @SamuelCho suggested this change, which gets rid of the warnings and doesn't appear to have introduced any graphical glitches.

Fixes #1382.
2017-06-21 14:50:41 -07:00
m!m 186f8ff5b9 Merge pull request #1376 from z64555/cleanup/lua_reporting
Adds LUA versioning and copyright info to the scripting.html output
2017-06-21 08:45:40 +02:00
m!m c86c4c3822 Merge pull request #1385 from MageKing17/bugfix/message-shipnum-ship-vanish
Avoid faulty assumption in message bracket code.
2017-06-21 08:42:22 +02:00
m!m bea9d56feb Merge pull request #1384 from MageKing17/bugfix/collision-group-sexp
Fix removing a collision group via SEXP.
2017-06-21 08:41:41 +02:00
Goober5000 dc6d2be515 Merge pull request #1381 from Goober5000/fix_default_operator_for_modify_variable
Fix handling of arguments for sexps that use variables
2017-06-21 01:49:31 -04:00
Tyler Blount 298ec5519c Merge pull request #1383 from MageKing17/bugfix/profiling-category-duplicate
Fix duplicate tracing/profiling category.
2017-06-20 21:02:24 -06:00
MageKing17 7025e3443e Avoid faulty assumption in message bracket code.
This assertion could apparently be hit if a ship was vanished (e.g. with ship-vanish) in the middle of talking. Rather than making the vanishing code aware of (and responsible for) Message_shipnum, it seemed simpler to just make hud_show_message_sender() clear the invalid shipnum itself.
2017-06-20 19:20:41 -07:00
Tyler Blount 88b87b86fc Merge pull request #1378 from asarium/fix/fredHasShields
Fix inverted "Has shields" flag in initial status dialog
2017-06-20 19:54:05 -06:00
asarium b34ca3cfed Fix handling of inconsistent values in initial status editor
The flagset changes probably broke this behavior by not respecting the "inconsistent" value set by the OnInit function when ships have inconsistent values for a specific flag. This should fix that and restore the 3.7.4 behavior.
2017-06-20 20:01:57 +02:00
z64555 1b2eece53a Adds LUA versioning info to the scripting.html output
* Credits roll now grabs the LUA copyright info from liblua, instead of being hardcoded
* Credits roll now has LUA version info as well
2017-06-20 08:22:25 -05:00
m!m 472a3f09f7 Merge pull request #1380 from TRBlount/qtfred2_dialogs
Add Team Loadout and Mission Objective editors
2017-06-20 08:48:06 +02:00
Goober5000 e8313fa577 fix handling of arguments for sexps that use variables 2017-06-19 20:04:15 -04:00
TRBlount d6c4ff374c Update Team Loadout and Mission Objective Editors
Changes the above editors to use dialog button boxes and spacer widgets
instead of min/max sizes.
2017-06-18 00:57:23 -06:00
TRBlount b14c12befa Add Mission Goal and Team Loadout Dialogs 2017-06-18 00:57:23 -06:00
Tyler Blount 2d7606740a Merge pull request #1377 from asarium/qtfred2_/dev
Add object creation and drag movement of ships
2017-06-18 00:57:00 -06:00
asarium 5a8454e956 Fix inverted "Has shields" flag in initial status dialog 2017-06-17 18:18:12 +02:00
asarium 1712a42807 Add abstracted dialog system 2017-06-17 15:52:36 +02:00
MageKing17 f6b1eaa846 Fix duplicate tracing/profiling category.
Cutscene audio decoding was accidentally named "FFmpeg decode video", causing some minor problems in the profiling code (because the same name is used for actual video decoding, resulting in an assertion firing).
2017-06-15 16:16:29 -07:00
MageKing17 d20ff9b367 Fix removing a collision group via SEXP.
sexp_manipulate_colgroup() was using logical NOT when it should've been using bitwise NOT, meaning that removing any collision group would remove all collision groups.
2017-06-15 15:49:51 -07:00
MageKing17 a3ab30cd96 Merge pull request #1374 from TRBlount/fix/lua_weapon_team
Make l_weapon use IFFs in Team var
2017-06-14 15:22:52 -07:00
asarium f811d7591f Remove the need to specify the editor pointer 2017-06-14 17:56:30 +02:00
asarium 7e9f0c8e6f Connect toolbar button for showing distances 2017-06-14 17:46:33 +02:00
TRBlount 48f76f7cd1 Fix l_weapon Team set var logic 2017-06-13 20:31:51 -06:00
asarium 255814dd4f Fix warning 2017-06-13 11:38:10 +02:00
asarium e076aa6990 Add briefing editor to main window and fix layout 2017-06-13 11:14:16 +02:00
asarium 16d48fbf1b Port object moving and creation code 2017-06-13 10:56:44 +02:00
Tyler Blount 937de9355b Merge pull request #1373 from asarium/qtfred2_/dev
qtFRED development changes
2017-06-12 00:57:55 -06:00
asarium 947b25e2cc Add executable icon 2017-06-11 23:20:02 +02:00
asarium e6f92f316a Move Briefing editor dialog to correct folder 2017-06-11 22:08:42 +02:00
asarium f65de9bb43 Fix compilation warning 2017-06-11 20:04:42 +02:00
asarium 956e908b6e Separate editor viewport state into separate class
This moves all the data related to the editor state that is not directly
connected to the renderer into its own class and file. This should
resemble the fredrenderer <-> fredview separation in the original FRED.
2017-06-11 20:04:41 +02:00
asarium 0442c1c6ac Fix case of Editor file 2017-06-11 20:04:40 +02:00
asarium 1a3b14316d Move init and shutdown stuff out of editor.cpp 2017-06-11 20:04:38 +02:00
asarium 350e8a2cf5 Add various selection modes including box selection 2017-06-11 20:04:37 +02:00
asarium 4cd9993640 Add Event dialog code 2017-06-11 20:04:36 +02:00
asarium 41137fedbd Begin adding dialog infrastructure 2017-06-11 20:04:34 +02:00
asarium 52901e7351 Add viewpoint status label 2017-06-11 20:04:33 +02:00
MageKing17 eb165123ac Merge pull request #1371 from MageKing17/bugfix/3d-framebuffer-shockwaves
Fix combining 3D shockwaves with framebuffer shockwaves.
2017-06-10 14:33:13 -07:00
MageKing17 526076f8ff Add AVX2 to the list of supported MSVC compiler optimizations.
Also adds AVX2 autodetection so that AVX2-capable processors will generate AVX2 projects by default. To my surprise, there is actually a noticeable performance increase between AVX and AVX2 builds.
2017-06-10 14:19:19 -07:00
MageKing17 c30ce55942 Fix combining 3D shockwaves with framebuffer shockwaves.
If framebuffer shockwaves were enabled and a 3D shockwave was created, FSO would use a hardcoded reference to the second slot of the Shockwave_info vector to generate the framebuffer shockwave for it. This only makes sense if and only if:
- the 3D shockwave command-line flag is also enabled
- the default 3D shockwave and default 2D shockwave are both present and loaded
- its the first mission of the session (because after that any shockwave not in the 0th index got unloaded)

I've changed the code so that which index the default 2D shockwave got loaded into gets tracked and used instead of a hardcoded index... and if both default shockwaves are loaded, the first two Shockwave_info indices are both kept between missions instead of just the first. This should allow framebuffer shockwaves to work with 3D shockwaves, regardless of whether or not it's the first mission of the session and whether or not a custom 2D shockwave was loaded (and happened to wind up at index 1). Slight downside in that missing the default 2D shockwave file, but having a custom 2D shockwave loaded, will now result in framebuffer shockwaves not being drawn at all, rather than using the custom 2D shockwave by accident; not sure that's really all that much of a problem, though.
2017-06-10 10:38:02 -07:00
m!m 8236a7d7f8 Merge pull request #1370 from TRBlount/Briefing_Editor
Add Briefing Editor Dialog
2017-06-10 11:42:44 +02:00
Tyler Blount 70e63dcf6c Fix include casing 2017-06-10 02:45:47 -06:00
TRBlount 557ff6be1d Add Briefing Editor Dialog 2017-06-10 01:37:16 -06:00
m!m 95896e6ec7 Merge pull request #1369 from asarium/qtfred2_/dev
Update qtFRED development files
2017-06-10 09:22:34 +02:00
m!m 9447d74da8 Merge pull request #1367 from Goober5000/invisible_beam_section_fix
Invisible beam section fix
2017-06-09 23:51:31 +02:00
asarium e6acd9a313 Add current ship control mode
Also fixed infinite recursion in key handler.
2017-06-09 23:16:06 +02:00
asarium c1cb978687 Fix context menu of RenderWindow 2017-06-09 18:58:53 +02:00
Goober5000 043e6a79a8 remove debug conditions when we are not in debug mode 2017-06-09 12:55:32 -04:00
Goober5000 97416feb2a Merge pull request #1368 from asarium/fix/1366
Remove abort call from debug_int3
2017-06-09 12:48:27 -04:00
asarium 51698af1b0 Add viewpoint switching 2017-06-09 13:57:30 +02:00
asarium 9d3659cf88 Fix UI file compilation 2017-06-09 11:34:52 +02:00
asarium 3eddce06dd Add buddies settings to EventDialog form 2017-06-09 11:19:11 +02:00
asarium 9c75a2178c Remove unneeded variable name parameter in CMake config 2017-06-09 11:05:17 +02:00
asarium d26253c5f8 Add an application icon
It's currently the normal FRED icon.
2017-06-09 10:55:28 +02:00
asarium aac3bbde8e Remove abort call from debug_int3
This fixes #1366.
2017-06-09 10:19:48 +02:00
asarium 6b5cac174a Add dialogs folder 2017-06-09 10:11:51 +02:00
asarium 1f39915a5e Add Event editor dialog form 2017-06-09 10:07:02 +02:00
asarium d60306288b Rebind movement speed shortcuts to fix camera movement 2017-06-09 10:06:55 +02:00
Goober5000 8f3ef45fc9 don't remove invisible beam sections 2017-06-08 22:18:02 -04:00
Goober5000 762997fc7d copy over more verbose assertions from light_add_cone 2017-06-08 22:17:24 -04:00
asarium 305e71e290 Copy display_distances code to fix rendering bug 2017-06-08 22:55:20 +02:00
asarium befe668c8b Remove deleted file from CMake config 2017-06-08 19:28:42 +02:00
asarium 25e87fb8a0 Use a timer with a 5 millisecond interval for our idle function
It uses less resources than the 0-interval timer.
2017-06-08 19:22:21 +02:00
asarium 9a11f232f6 Call super function in event filter 2017-06-08 19:11:01 +02:00
asarium 49a37ccf91 Fix view speed changing 2017-06-08 19:08:52 +02:00
asarium ee8d03b4cf Fix onIdle behavior 2017-06-08 19:07:02 +02:00
asarium 16b80faaaf Fix Travis CI warnings 2017-06-08 18:42:13 +02:00
asarium 0f7810fdb4 Add support for changing movement speed 2017-06-08 16:19:30 +02:00
asarium f85dfbb048 Add support for hiding objects
Also cleaned up some parameter handling
2017-06-08 15:32:47 +02:00
asarium 96ed407dd7 Fix endless loop 2017-06-08 13:04:36 +02:00
asarium cd7cf82430 Use render widget as focus proxy to redirect key events 2017-06-08 13:00:14 +02:00
asarium cff16f7b0b Remove object iterator 2017-06-08 12:49:06 +02:00
asarium 1a08bfa3e7 Handle window activation and deactivation 2017-06-08 12:39:45 +02:00
asarium dbc52e2aa7 Add handling of different cursor modes 2017-06-08 12:21:12 +02:00
asarium b1725bae76 Separate RenderWidget and RenderWindow
RenderWindow now only handled rendering and RenderWidget handles GUI
interaction by intercepting all GUI events for the RenderWindow.
2017-06-08 11:08:00 +02:00
asarium 4b10c61a5f Add initial cursor handling 2017-06-08 09:39:28 +02:00
asarium c18220048d Add handling of control constain buttons 2017-06-07 18:53:19 +02:00
asarium 08b8c1d768 Permanently create view popup menu 2017-06-07 17:56:39 +02:00
asarium 0f6a61894a Prevent context menu on the toolbar 2017-06-07 17:22:19 +02:00
asarium 3345aee144 Add viewport context menu
Still not complete but most actions are there already
2017-06-07 17:20:10 +02:00
asarium 207d3e6eba Continually update the view settings 2017-06-07 16:09:36 +02:00
asarium 8be0a19a98 Use a more elegant signal-slot solution for view option handling 2017-06-07 13:02:05 +02:00
asarium b517a47f81 Handle view settings updates 2017-06-07 12:35:51 +02:00
asarium 4afd5d9d1c Use normal event handler instead of event filter for shortcut override 2017-06-07 12:05:56 +02:00
asarium 7eaff0e63f Synchronize view settings with renderer settings 2017-06-07 10:52:10 +02:00
asarium 755df8c38b Fix crash when there is no valid filename 2017-06-07 10:51:56 +02:00
m!m 8357964e53 Merge pull request #1365 from asarium/qtfred2_/dev
Further qtFRED development
2017-06-07 10:38:54 +02:00
asarium e10b431735 Reformat FredView to fix GCC whitespace warning 2017-06-07 09:34:22 +02:00
asarium be5d7cc2cd Move most view parameters into the view struct 2017-06-06 23:42:41 +02:00
asarium 2e016ccffb Add support for storing recent files 2017-06-06 22:52:07 +02:00
asarium 4305649a64 Use standard key combinations for common actions 2017-06-06 22:51:42 +02:00
asarium 27c971a92b Actually fix MSVC 2013 compilation 2017-06-06 10:12:35 +02:00
asarium 1e1c8c7cb8 Actually add event based redrawing 2017-06-06 10:07:00 +02:00
asarium 94bb727ebe Fix MSVC 2013 compilation 2017-06-06 09:45:37 +02:00
MageKing17 43a46641eb Merge pull request #1364 from The-E/UnknownShips
Handle ships removed from play via ship-vanish correctly in ai goal processing
2017-06-05 20:58:40 -07:00
m!m 884259fc14 Merge pull request #1360 from asarium/qtfred2_/editorSignals
Add signals to Editor class and implement window title switching
2017-06-05 21:47:19 +02:00
asarium 0b6a3115a7 Load debug filer file at startup 2017-06-05 19:13:52 +02:00
asarium ec6a786654 Create default ship on mission start 2017-06-05 18:02:16 +02:00
Fabian Woltermann 47bd990bca Handle ships removed from play via ship-vanish correctly in ai goal processing. 2017-06-05 15:00:10 +02:00
asarium a3744d8818 Fix installation step for FastDebug 2017-06-05 14:51:09 +02:00
asarium 5dc0c0d98d Add the Qt main code to fix compilation issues with FastDebug
This also removed the need to link the runtime dynamically.
2017-06-05 00:34:36 +02:00
asarium ad6551cf38 Override shortcuts when the key is on the key pad
This fixes the movement speed shortcuts
2017-06-04 15:57:12 +02:00
asarium 1cdc0840be Connect Open and New actions 2017-06-04 14:00:28 +02:00
asarium e7f619d65e Refactor render handling and editor separation 2017-06-04 13:44:22 +02:00
m!m ec3313ffea Merge pull request #1363 from MageKing17/bugfix/generic-anim-static-png
Reset generic animation type to BM_TYPE_NONE if APNG processing fails.
2017-06-04 09:40:27 +02:00
MageKing17 f2c099a7a9 Reset generic animation type to BM_TYPE_NONE if APNG processing fails.
Prior to APNG support, a regular non-animated PNG could be used as a still-frame command briefing animation. This started causing a crash when APNG support was added because any PNGs sent through generic_anim_stream() would get ga->type set to BM_TYPE_PNG, then sent through the APNG code... which would determine that they weren't APNGs, throw an ApngException, and generic_anim_stream() would return -1... except that BM_TYPE_PNG would still be set, so that when it later came time to render the still frame in generic_frame_render(), it would be sent through generic_anim_render_variable_frame_delay()... which expected a fully-formed APNG, tried to dereference ga->png.anim, and crashed.

This commit is a simple fix to reset ga->type to BM_TYPE_NONE if APNG processing fails, allowing the still-frame PNG to go through generic_anim_render_fixed_frame_delay(), the code path it used to take, and allowing it to display properly instead of crashing.
2017-06-03 22:07:52 -07:00
asarium 3ddc93fd9d Remove speed shortcuts to fix cmaera controls for now 2017-06-03 11:01:02 +02:00
asarium 6b32bdb732 Make sure our viewport is in use when updating the window 2017-06-02 22:21:09 +02:00
asarium cabc6f6412 Add organization and application names 2017-06-02 19:40:14 +02:00
asarium 164e20ef96 Remove usage of Qt in editor code 2017-06-02 19:24:12 +02:00
asarium d18b97014e Fix Unix compilation 2017-06-02 17:20:28 +02:00
asarium abdf713944 Add manifest for Windows 2017-06-02 17:16:54 +02:00
Fabian Woltermann e6c6cc3864 Merge pull request #1352 from asarium/feature/trackIr64bit
Use TrackIR DLL with 64 suffix when compiling a 64-bit build
2017-06-02 11:10:42 +02:00
asarium 24a3369e9d Make sure member is initialied with a valid value 2017-06-01 23:47:32 +02:00
asarium cb94183629 Implement user name retrieval on Windows 2017-06-01 23:47:15 +02:00
asarium 7ecfa209ca Add Ship class combo box
This is still a few features of the old combobox.
2017-06-01 22:57:42 +02:00
asarium 22105d1e3e Use FredView as the new main window 2017-06-01 21:46:12 +02:00
m!m 5ee1b6d243 Merge pull request #1362 from MageKing17/cleanup/shockwave-vector-usage
Cleaning up the shockwave code's use of vectors and assertions.
2017-06-01 21:24:28 +02:00
MageKing17 3577c005e2 Merge pull request #1357 from asarium/fix/openglIncludes
Remove include of OpenGL header in non-OpenGL code
2017-06-01 12:11:09 -07:00
MageKing17 b2891bfe21 Merge pull request #1361 from MageKing17/bugfix/auto-convergence-min-distance
Allow "+Minimum Distance:" to actually work with automatic convergence.
2017-06-01 12:10:32 -07:00
MageKing17 82aa027d0d Cleaning up the shockwave code's use of vectors and assertions.
After someone tripped an assertion in the shockwave code which provided no details, I found some... questionable vector-related code. I changed all the code I could find that looped through the vector with iterator-based code, converted most Asserts into Assertions for more informative debugging, and added a couple Assertions to check previously-unchecked assumptions (which theoretically should never be tripped, but we'll see). A test build with the vector fixes resulted in the assertion no longer tripping so I'm fairly sure the improper erasure of the vector was causing problems (leftover data from a previous mission with a model number that no longer made sense because the model was unloaded).
2017-06-01 11:38:44 -07:00
asarium 588659a367 Rename frmFRED to match the name of the original FRED name 2017-06-01 11:40:49 +02:00
z64555 423d14c24a Add (another) UI for main window, mainwindow.ui is slated to be removed. 2017-06-01 11:27:42 +02:00
asarium 2f44c3242f Convert XPM to PNG and add images to resources 2017-06-01 11:19:14 +02:00
z64555 1167a4edcb Include art assets for UI 2017-06-01 11:04:40 +02:00
asarium 862010b4e0 Fix Qt config for mac 2017-06-01 10:46:02 +02:00
asarium 95dff1dacf Port mission clear code to qtfred 2017-06-01 10:40:43 +02:00
asarium bc38232f3a Use Qt 5.7 for Travis 2017-05-31 21:55:51 +02:00
asarium a29708ea89 Reformatted FredRenderer 2017-05-31 18:24:08 +02:00
asarium baeb9ac78b Improve handling of fredGlobals 2017-05-31 10:02:37 +02:00
asarium 211b9c9d71 Install custom Qt message handler 2017-05-31 09:44:55 +02:00
asarium 4c05a103fa Improve startup window display
Windows will now only be displayed once startup is complete and not when
the graphics code is initialized.
2017-05-31 00:29:42 +02:00
asarium 540e52ffbc Forward unused keyboard event to render window 2017-05-31 00:08:43 +02:00
MageKing17 902d40f3df Allow "+Minimum Distance:" to actually work with automatic convergence.
The gun convergence code would detect if the target was within the minimum distance and move the predicted target point farther away if so, but wouldn't also alter the dist_to_aim variable to match; since predicted_target_pos is used by the autoaim code while dist_to_aim is what automatic convergence uses, this meant automatic convergence didn't respect the minimum distance at all.

Looks like this was broken in 7bb10d8408.
2017-05-30 09:52:27 -07:00
m!m e82fc4ac2f Merge pull request #1359 from MageKing17/bugfix/rearm-loading-start-sounds
Allow rearm start sound effects to actually play.
2017-05-29 11:41:51 +02:00
MageKing17 71673241fd Allow rearm start sound effects to actually play.
SND_MISSILE_START_LOAD and SND_BALLISTIC_START_LOAD (indices 33 and 200, respectively) could never actually play due to a logic error (they checked that a variable was true and the loop was on the last bank, when those conditions being met earlier in the function set that same variable to false). As far as I can tell, this broke back in 2006 with commit f300716e93.
2017-05-29 01:40:13 -07:00
m!m 0fc55babaf Merge pull request #1356 from asarium/qtfred2
Initial QtFRED source code
2017-05-29 10:10:54 +02:00
Fabian Woltermann f93cb23d43 Merge pull request #1358 from asarium/fix/fastDebugDebugging
Use correct variable when copying linker flags to fast debug
2017-05-29 09:48:36 +02:00
asarium 0415b69407 Use correct variable when copying linker flags to fast debug
This broke the release debugging flag for fast debug which should be
fixed by these changes.
2017-05-29 09:19:18 +02:00
asarium 4ce085cd49 Add signals to Editor class and implement window title switching 2017-05-29 09:18:15 +02:00
asarium 3edb4575d3 Fix Visual Studio 2015 compiler bug 2017-05-28 22:50:25 +02:00
asarium 26af516704 Fix gtest variable for forced shared crt 2017-05-28 18:59:18 +02:00
asarium 668dccf925 Use dynamic runtime and disable FRED compilation 2017-05-28 14:34:35 +02:00
asarium acdf88fdeb Set focus policy for render widget 2017-05-28 14:28:59 +02:00
asarium 577c49eedb Add appveyor qt configuration 2017-05-28 14:08:55 +02:00
asarium 9cd3d80b81 Change setOption usage for Qt 5.2 compatibility 2017-05-28 13:51:48 +02:00
asarium e8316662b8 Improve update behavior 2017-05-28 13:23:59 +02:00
asarium 6a82c1eee7 Reformat file 2017-05-28 13:04:49 +02:00
asarium a309cb51b1 Add assertions for making sure a renderer exists 2017-05-28 13:02:28 +02:00
asarium af60cefbd5 Include QWidget header to fix compilation 2017-05-28 12:35:01 +02:00
asarium 8e2b1f354a Add message if dynamic runtime is not enabled 2017-05-28 12:32:02 +02:00
asarium 1d3ee16198 Remove unused field and fix brace warning
The fields were also unused by the previous FRED renderer so we are not
simply missing the code that used them.
2017-05-28 11:39:26 +02:00
asarium cb7f2a5dfd Remove unused include 2017-05-28 11:23:51 +02:00
asarium 18a621764c Fix warnings in FredRenderer 2017-05-28 10:48:35 +02:00
asarium 22c7e31c8a Merge branch 'fix/openglIncludes' into qtfred2 2017-05-28 10:36:01 +02:00
asarium e4775948d7 Remove include of OpenGL header in non-OpenGL code 2017-05-28 10:35:33 +02:00
asarium 00ff9e8751 Correct message referencing wxFRED 2017-05-28 10:32:15 +02:00
asarium ba26f6e221 Add Travis CI configuration 2017-05-28 10:21:28 +02:00
asarium ed01e155f6 Fix typo 2017-05-28 09:58:17 +02:00
asarium cd110bb2c1 Some minor improvements to the main function 2017-05-28 09:30:00 +02:00
asarium 2c30dbcda6 Add better control of viewport destruction order 2017-05-27 23:51:39 +02:00
asarium 160d49fa82 Remove unused function 2017-05-27 23:03:27 +02:00
asarium 431ad4144f Fix Visual Studio uni test compilation with shared runtime 2017-05-27 23:03:00 +02:00
asarium 2555d11427 Use lambda instead of std::bind 2017-05-27 21:52:54 +02:00
asarium e1882fc314 Add better mechanism for specifying Qt install root 2017-05-27 21:52:30 +02:00
asarium 2804b5d9d3 Update rendering handling. 2017-05-27 20:39:24 +02:00
asarium 2bbe201130 Various changes while trying to find cause for shutdown crash 2017-05-27 19:04:36 +02:00
asarium bbbc08fa87 Fix borders around render widget 2017-05-27 19:04:21 +02:00
asarium a8def1e1b3 Improve CMake setup, now has proper source folder support 2017-05-27 19:02:53 +02:00
asarium 987a442dd6 Reorganize QtFRED file structure 2017-05-27 13:26:30 +02:00
asarium 09d39da97c Remove unneeded renderer initialization 2017-05-27 13:14:11 +02:00
asarium 0a2e6f581b Add commandline parsing
Also fixed some initialization inconsistencies
2017-05-27 11:37:45 +02:00
asarium 98cde8f21f Fix XSTR related crash when loading a mission 2017-05-27 11:05:42 +02:00
asarium 9d22d75ba8 Add claifying comment in main 2017-05-27 11:05:29 +02:00
asarium df095e6bdf Fix various Qt and rendering issues
Now this is actually able to show the mission grid (but mission loading
still fails).
2017-05-27 09:55:06 +02:00
asarium 243f7f7ce8 Disable memcpy checks if third party libraries are used 2017-05-25 23:46:10 +02:00
asarium 32b6696162 Fix qtfred code 2017-05-25 23:42:44 +02:00
asarium ac8befa4e6 Reimport previous qtfred source 2017-05-25 23:42:32 +02:00
asarium 8958de35bc Use TrackIR DLL with 64 suffix when compiling a 64-bit build
This should make it possible to have both DLL version installed at the
same time without causing conflicts.

Combined with the new DLL, this will finally fix #974.
2017-05-18 10:52:25 +02:00
m!m c03dbea7ea Merge pull request #1349 from MageKing17/bugfix/avoid-rank-int3
Avoid Int3() when finding a rank with an out-of-order points value.
2017-05-18 09:11:12 +02:00
MageKing17 9107da8c9c Merge pull request #1351 from asarium/fix/1350
Readd warning dialog counting
2017-05-17 09:55:06 -07:00
MageKing17 1abb1833aa Avoid Int3() when finding a rank with an out-of-order points value.
There's a bit of debug code that checks to make sure all ranks are in ascending point order; if this check fails, FSO calls Int3() instead of trying to describe the problem. I've changed it to a Warning that actually explains the problem, so the modder can fix it.
2017-05-17 09:03:32 -07:00
asarium a2e70b8c5c Readd warning dialog counting
This fixes #1350.
2017-05-17 17:14:12 +02:00
Fabian Woltermann 1029de8073 Merge pull request #1348 from asarium/fix/hudReticleInt3
Remove unneded Int3 in hudreticle.cpp
2017-05-07 17:57:32 +02:00
asarium 3abcb24815 Remove unneded Int3 in hudreticle.cpp
The code works perfectly find without it and it causes issues with a
release campaign so there is no reason to keep it.
2017-05-07 17:20:48 +02:00
m!m 13d68bdfc6 Merge pull request #1347 from MageKing17/bugfix/cmdline-double-parse
Stop parsing cmdline_fso.cfg twice in legacy mode.
2017-05-06 12:05:19 +02:00
Fabian Woltermann de0bbaa4f6 Merge pull request #1339 from asarium/fix/mantis3195
Revert bad fix for Coverity issue
2017-05-06 11:35:39 +02:00
MageKing17 ce569d400e Stop parsing cmdline_fso.cfg twice in legacy mode.
os_init_cmdline() contains the legacy-mode codepath in a conditional, but then doesn't put the non-legacy mode code in an else branch, resulting in cmdline_fso.cfg getting processed twice, leading to e.g. every mod getting loaded twice (which can cause all kinds of issues). This just wraps the non-legacy code in an else branch so that FSO running in legacy mode won't do both.
2017-05-05 17:23:02 -07:00
MageKing17 adb94dc4d2 Merge pull request #1346 from The-E/anim_load_fix
Adds a small sanity check after reading an ani header
2017-05-05 01:17:36 -07:00
MageKing17 916082d910 Merge pull request #1345 from asarium/fix/1344
Save mission flags using correct format specifier
2017-05-05 01:16:36 -07:00
Fabian Woltermann e52f23d45d Adds a small sanity check after reading an ani header 2017-05-04 19:18:06 +02:00
asarium 2dfc086c94 Add unit test for checking numeric conversions 2017-05-02 11:47:21 +02:00
asarium 0a53aff061 Clean up flagset handling of numeric values
This renames the functions exposed by flagset so that it's clear that
64-bit values are returned. This also cleans up usages of wrong format
specified when that value is printed which caused some issues in the
past.

This should also fix #1336.
2017-05-02 10:28:29 +02:00
asarium 2dab381e88 Save mission flags using correct format specifier
The current version simply writes the flagset object as an integer to
the mission file which surely will cause issues.

This fixes #1344.
2017-05-02 09:57:19 +02:00
MageKing17 83514409f3 Merge pull request #1334 from asarium/fix/laserParticleEffect
Fix assertion when applying particle effect to laser
2017-04-26 09:57:08 -07:00
Cliff Gordon 340f39f44d Merge pull request #1343 from asarium/build/appveyorFTPKeys
Fix encrypted login data for appveyor FTP upload
2017-04-26 07:40:24 -05:00
m!m 418a944127 Merge pull request #1341 from chief1983/fix/solaris_math_h
Fix several issues blocking a Solaris compile
2017-04-26 10:19:33 +02:00
asarium 22180c0b45 Fix encrypted login data for appveyor FTP upload
I encrypted those values using my user instead of our SirKnightly
account which meant that the values failed to decrypt. These new values
were encrypted using the SirKnightly user which should allow Appveyor to
upload the nightly builds to our FTP servers.
2017-04-26 10:15:11 +02:00
Cliff Gordon 2949ca2628 Merge pull request #1342 from asarium/build/ftpNightlies
Upload nightly builds to FTP instead of BinTray
2017-04-25 13:54:43 -05:00
asarium dbf952e031 Upload nightly builds to FTP instead of BinTray
Since BinTray may be unreliable as our nightly host @chief1983 and I
decided that it would be best to return hosting to our dedeicated FTP
servers. These changes implement that together with a pending pull
request for the nightly script.
2017-04-25 19:55:34 +02:00
m!m 21cc93ffd6 Merge pull request #1340 from asarium/fix/bintrayKeys
Update BinTray API keys
2017-04-24 20:32:38 +02:00
m!m c06ed08e74 Merge pull request #1338 from MageKing17/bugfix/duplicate-percent-signs
Get rid of duplicate percent signs in the statistics screen.
2017-04-24 20:02:47 +02:00
asarium 89a9932ac5 Update BinTray API keys
While searching for the cause of the rate-limiting of our BinTray
organization, I revoked the API key used by the CI servers in case the
key got compromised somehow. These are the updated keys which should
allow us to upload nightly builds again.

@chief1983 and I are working on a nightly solution which does not
require BinTray but until that works we need these updated keys.
2017-04-24 19:49:22 +02:00
asarium 5b1285e608 Revert bad fix for Coverity issue
fa60c666bc tried to fix an issue reported
by Coverity which was an intentional "issue". This restores the original
behavior which will cause a new coverity issue which can be ignored.

This fixes Mantis 3195.
2017-04-24 11:16:11 +02:00
MageKing17 d5d33379a3 Get rid of duplicate percent signs in the statistics screen.
The problem was caused by an oversight in 07107ce9b2 (namely, that changing some strings from being passed directly to string-formatting to being passed as arguments to a "%s" format-specifier meant that "%%" was no longer needed to get a plain "%" out the other side).
2017-04-23 10:42:25 -07:00
Cliff Gordon accbc1d25d See if this helps with the linking errors for libsocket and libnsl symbols. 2017-04-21 15:12:15 -05:00
Cliff Gordon 8acff8e02c Add the INTEL_LONG define that was added to the other two blocks last year but not to Solaris. 2017-04-21 14:26:13 -05:00
Cliff Gordon 89d13ab774 fix/solaris_math_h: Attempt to work around the version symbol conflict. 2017-04-21 14:08:54 -05:00
m!m 8850efce7f Merge pull request #1333 from oldlaptop/openbsd
Fix the build on OpenBSD
2017-04-16 10:34:56 +02:00
oldlaptop 4b36e3c379 add platform check for std::is_trivially_copyable
Yes, the template instantiation appears necessary for cmake to
 detect the type. If there's a better type for it than int, I'm
 open to suggestions.
2017-04-15 22:06:47 -04:00
asarium c008dfc303 Fix assertion when applying particle effect to laser
The weapon state value of the weapon was updated after the particle
source was created so the source was always invalid which caused an
assertion.
2017-04-14 23:50:12 +02:00
oldlaptop 8f76537b02 s/_L/L_State
The iterator known as _L, besides having an absurdly poor name,
 clashes with standard headers on OpenBSD -current at the time
 of writing. This commit is the minimum needed to build on
 OpenBSD with an updated C++ standard library.
2017-04-13 09:06:48 -04:00
m!m 36ae38a532 Merge pull request #1330 from niffiwan/fix/1329
Tweak autodraw shield bar positions
2017-04-04 09:47:25 +02:00
niffiwan bcf49b9630 Fix const var names & style 2017-04-04 17:10:03 +10:00
niffiwan 654f3545fc Tweak autodraw shield bar positions
See #1329, this makes the rear shields slightly further away from the
front, so that the model clip area matches the area where the shields
are drawn.
2017-04-03 20:10:05 +10:00
niffiwan 37575b2fea Merge pull request #1327 from asarium/fix/1326
Apply clipping planes to passthrough shader
2017-04-01 14:14:33 +10:00
asarium 6ddca15dc5 Apply clipping planes to passthrough shader
This adds support for using clipping planes with the passthrough shader
by passing through the clip equation of the specified plane and then
using gl_ClipDistance for using the built-in clipping capabilities.
2017-03-30 23:26:20 +02:00
Fabian Woltermann 353c28176c Merge pull request #1325 from asarium/fix/1059
Validate seek offsets in cfseek
2017-03-29 14:20:25 +02:00
Fabian Woltermann 4815343854 Merge pull request #1324 from asarium/feature/loadTracing
Add tracing scopes to the mission load code
2017-03-29 10:20:07 +02:00
asarium 4e18f01438 Validate seek offsets in cfseek
Invalid values previously corrupted the internal position counter which
caused crashes on some platforms because the position counter would
overflow in the next read operation. I added some assertions to track
the position counter corruption and it's probably a good idea to leave
them in to catch possible future errors early.

The actual fix was to just ensure that the seek position it always valid
for the file.

This fixes #1059.
2017-03-29 10:17:27 +02:00
asarium abdef9f7b0 Add tracing scopes to the mission load code
This makes it easier to determine what takes the most time while loading
the mission (loading models) and how we could optimize that load time
(optimize model loading).

This is not a bug fix but it also shouldn't cause any regressions since
there are no actual code changes so this could be merged before the
release of 3.8.
2017-03-28 17:23:22 +02:00
Fabian Woltermann f67a42d89e Merge pull request #1319 from asarium/fix/envmapHandling
Improve handling of environment map redrawing
2017-03-26 08:37:50 +02:00
Fabian Woltermann 52b48bd32d Merge pull request #1321 from asarium/opengl/builtInClipPlane
Use built-in OpenGL clip plane instead of custom variant
2017-03-26 08:37:32 +02:00
Fabian Woltermann ad2fcfd22f Merge pull request #1322 from asarium/fix/distortionErrors
Fix OpenGL errors when framebuffer effects are disabled
2017-03-25 20:28:01 +01:00
asarium 507f50cd90 Fix OpenGL errors when framebuffer effects are disabled
This also promotes medium and high severity OpenGL messages to the
general logging category to help troubleshooting in the future.
2017-03-25 19:46:52 +01:00
asarium d91739b41d Use built-in OpenGL clip plane instead of custom variant
The current shaders compute the clip values in the vertex shader and
then discard fragments if those values say that the fragment is clipped.
I don't know why this was done but, as far as I can tell, this behavior
can be fully replaced by using the built-in OpenGL clip-plane feature
which should also reduce the amount of fragment shader invocations. This
won't affect performance too much since we rarely use clip planes but it
seems like the correct thing to do.
2017-03-25 00:05:48 +01:00
asarium b9413a2639 Improve handling of environment redrawing
This should make sure that the environment map is only redrawn if
necessary. In my case that should improve frame times by around 1ms for
the normal case when the environment map doesn't need to be redrawn.
2017-03-22 17:01:28 +01:00
niffiwan e003d08249 Fix lua function documentation 2017-03-20 20:37:38 +10:00
niffiwan bb94d5bcd6 Merge pull request #1196 from asarium/fix/sprintfAttribute
Add format string annotations to all printf style functions
2017-03-20 20:19:43 +10:00
niffiwan c8baf8b344 Don't assume sexp will have all RGB supplied
Fix annoying clang pedantry with union aggregate init lists
2017-03-19 16:01:20 +10:00
niffiwan b5f75af66e Allow tint shader to be controlled by sexp & lua
i.e. the RGB values can be set/changed
2017-03-19 12:52:51 +10:00
m!m 8caaf5c00c Merge pull request #1314 from SamuelCho/macDeferredLightingFix
Reorder fragment shader destination binds to fix Mac deferred lighting.
2017-03-17 16:59:24 +01:00
SamuelCho 7db1861b59 Corrected shoddy copy paste job involving shader program handle in the bind fragment data fix. 2017-03-17 08:28:12 -07:00
SamuelCho fabdc6ab8a Make sure we bind the fragment shader destinations before we link the shader. 2017-03-16 20:41:09 -07:00
asarium 07107ce9b2 Fix newly introduced format warnings 2017-03-15 19:34:11 +01:00
asarium 2a4795596f Add format string annotations to all printf style functions
This should help to catch most if not all printf mistakes since those
can then be caught by our CI.
2017-03-15 19:34:11 +01:00
Samuel Cho caaaf3213d Merge pull request #1313 from asarium/fix/1307
Fix OpenGL distortion map update
2017-03-13 20:05:43 -07:00
asarium e119be513b Fix OpenGL distortion map update
The updated values for the distortion map were rendered too close to the
edge of the screen so they were clipped which meant that there was no
distortion data available. This fixes that by moving the rendered
primitives farther away from the edge. I'm not sure why this worked in
3.7.4, maybe the fixed function rendering used some slightly different
matrix.

I also don't know why this wouldn't work consistently across GPU vendors
but maybe the rasterization rules vary a bit across drivers.

This fixes #1307.
2017-03-13 20:09:08 +01:00
Fabian Woltermann 09524fb9fe Merge pull request #1311 from SamuelCho/renderTargetNoLightingModelFix
Fix for intense glare when rendering a model in a render target with no lighting.
2017-03-13 08:43:51 +01:00
SamuelCho 9b5e7ce19d Clamp the dot product of eye direction and surface normal to prevent intense glare when rendering a model in a render target with no lighting. 2017-03-12 18:36:45 -07:00
niffiwan 25415342ea Add colour-configurable tint shader
FotG needs a tint shader for a feature; basically toggle screen tinting
when a key is pressed as a visual indicator of which mode your ship it
in. Was previously done in a custom shader.
2017-03-12 22:04:33 +10:00
niffiwan e39a8bbed3 Merge pull request #1305 from asarium/fix/lightshaftCockpit
Fix lightshaft rendering with cockpits
2017-03-11 10:29:39 +10:00
niffiwan d224a87828 Merge pull request #1302 from asarium/fix/openglInitError
Extend display device initialization error
2017-03-11 10:29:10 +10:00
m!m 78df244bc7 Extend display device initialization error
This should make it clearer what went wrong.
2017-03-10 23:41:14 +01:00
asarium 6718a1aba8 Fix lightshaft rendering with cockpits
Immediately clearing the z-buffer is definitely not a good way of
saving it for later use. This fixes the lightshaft rendering (which was
broken by my fix in #1282) by removing the depth buffer clear from the
z-buffer restore function. The z-Buffer is cleared anyway before
rendering into it so it shouldn't make a difference.
2017-03-10 23:34:16 +01:00
Samuel Cho 9d7c5a2b17 Merge pull request #1304 from TRBlount/shield_decal_correction
Correct shield decal selection logic
2017-03-10 12:12:39 -08:00
TRBlount f4ccab0f9f Correct shield decal logic 2017-03-10 12:10:45 -07:00
Fabian Woltermann 4bfdb9bdf0 Merge pull request #1299 from asarium/fix/sexpVarNull
Correctly terminate Sexp_variable text with a null byte
2017-03-10 18:59:53 +01:00
asarium 2b9441eeb6 Correctly terminate Sexp_variable text with a null byte
I'm pretty sure that this is a bug since the documentation of
std::string::copy says that it doesn't append a 0 byte so our code would
need to do it manually. Instead, the code appended the 0 byte to the
input buffer which also conflicts with const-correctness (the function
was used on a lua-string buffer which should be const outside Lua).
2017-03-09 18:56:42 +01:00
niffiwan 9b1b3e0a74 Merge pull request #1296 from The-E/RestoreFlagWindows
Restore the flag viewers
2017-03-08 22:48:22 +10:00
niffiwan d7a6a94808 Merge pull request #1297 from The-E/UselessWarningRemoval
Remove a couple of annoying warnings in ship flag parsing
2017-03-08 22:47:13 +10:00
Fabian Woltermann f49cad0e32 Change a few flag warnings that really do not need to be warnings to simple log prints. 2017-03-08 08:56:52 +01:00
Fabian Woltermann d2f853f601 Apparently VS2013's auto doesn't correctly resolve these? 2017-03-08 08:45:42 +01:00
Fabian Woltermann d544d42448 Addressing CI issues 2017-03-08 08:35:54 +01:00
MageKing17 3d027dc7bc Merge pull request #1295 from asarium/fix/outwndHeader
Fix log header printing
2017-03-07 19:10:55 -08:00
Fabian Woltermann 163e9175e9 Cleanup 2017-03-08 00:30:36 +01:00
asarium 91fda5386a Fix log header printing
Due to some initialization order issues the original header string
wasn't printed to the log anymore. This fixes that by initializing
outwnd_inited before doing the initial outwnd_print.
2017-03-07 23:31:47 +01:00
Fabian Woltermann 63e610e07d Rerstore the flag viewers 2017-03-07 22:31:33 +01:00
m!m 26d6e0f56f Merge pull request #1288 from SamuelCho/lightingFixes
Lighting attenuation fixes and deferred tube light stencil test removal
2017-03-07 09:47:49 +01:00
m!m aafbfb7277 Merge pull request #1291 from SamuelCho/materialSetColorFix
Fixed color struct to vec4 color conversion in material class.
2017-03-07 09:47:09 +01:00
SamuelCho 7c4e564c92 Fixed color struct to vec4 color conversion in material class. 2017-03-06 23:50:18 -08:00
SamuelCho fc5895a910 Removed stencil test setup in deferred lighting pass. 2017-03-06 23:25:51 -08:00
SamuelCho 51b4d62007 Merge branch 'master' into lightingFixes 2017-03-06 23:09:52 -08:00
niffiwan 497173d3e2 Merge pull request #1287 from asarium/fix/mantis3193
Output briefing icon lables as XSTRs
2017-03-06 19:40:19 +10:00
SamuelCho 2118cc42f0 Fixed reordered deferred lighting shader operations to ensure attenuation correctness. Killed deferred stencil operations for tube lights. Corrected attenuation in forward rendering shader. 2017-03-05 23:09:44 -08:00
asarium 4a8147dae2 Output briefing icon lables as XSTRs
The briefing icon lables previously just wrote the label string to the
mission files without surrounding it with an XSTR which made is
impossible to translate them. I fixed that by using the right function
call when saving the value.

This fixes Mantis 3193.
2017-03-05 22:00:52 +01:00
Fabian Woltermann c9763b0623 Merge pull request #1286 from asarium/fix/cmakeDebugPrints
Remove CMake debug print statements
2017-03-05 21:36:30 +01:00
m!m 63ecfcff6b Remove CMake debug print statements
I accidentally left these in an earlier pull request and they are not supposed to be here.
2017-03-05 18:41:12 +01:00
Fabian Woltermann a1670f9e1d Merge pull request #1283 from asarium/fix/localizedKeyPress
Always use the english key name in the scripting interface
2017-03-05 13:22:12 +01:00
Fabian Woltermann 1287cfacae Merge pull request #1282 from asarium/fix/cockpitDepthBuffer
Fix depth test of lasers when using a cockpit ... again
2017-03-05 13:21:04 +01:00
Fabian Woltermann d8fac09281 Merge pull request #1281 from asarium/fix/luaTrivialTypes
Disallow to use non-trivial types as scripting handles
2017-03-05 13:20:03 +01:00
Fabian Woltermann 3ac9821907 Merge pull request #1280 from asarium/fix/dradisColorIcon
Restore color icon behavior in DRADIS HUD gauge
2017-03-05 13:19:15 +01:00
asarium e7a923bef6 Always use the english key name in the scripting interface
Previously, the key text would use the localized key name which made it
hard for scripts to consistently handle key presses across different
languages. This changes that interface so that it always returns the
english name of the key.
2017-03-04 20:11:29 +01:00
asarium 840c1802e6 Use libc++ for clang builds on Travis CI
This should ensure that our code also works with that C++ standard
library implementation and should catch more cross-platform
incompatibilities.
2017-03-04 16:47:14 +01:00
asarium 772a02f56f Disallow to use non-trivial types as scripting handles
As described in #1278, the current scripting system has issues with
handling non-trivial C++ types. Since fixing that deficiency is too much
work, especially since we are in a feature freeze, I decided to simply
enforce the usage of trivial types for scripting handles. Fortunately,
only two handles used non-trivial types so it was relatively easy to fix
those instances by dynamically allocating those and only storing the
pointers in the lua memory.

This fixes a bug in JAD-XA where the game would crash at the last boss.

Also, I noticed that the HudGauge handle used a copy of the hud gauge
rather than a pointer to the actual instance so I'm pretty sure that any
scripting changes to a custom HUD gauge simply didn't work before.
2017-03-04 16:16:22 +01:00
asarium 6a803c0550 Fix depth test of lasers when using a cockpit ... again
This introduces code to explicitly restore the z-buffer binding to the
previous value instead of relying on the lightshaft code to restore it.
2017-03-04 15:59:13 +01:00
asarium 485a5989c8 Restore color icon behavior in DRADIS HUD gauge
The DRADIS has two icon types, one where the color is scaled with the
IFF color and once which isn't. Due to a regression, both icons were
previously scaled with the IFF color which made the icons look bad. This
fixes that.
2017-03-04 13:12:03 +01:00
niffiwan 10bbead9ec Merge pull request #1270 from asarium/fix/bmpmanAssert
Require that the energy bar animation has 4 frames
2017-03-04 11:44:16 +10:00
MageKing17 aea4d1d414 Merge pull request #1277 from asarium/fix/weaponDescriptingLength
Fix assertion failure in weapon choice screen
2017-03-03 15:21:59 -08:00
MageKing17 3a321251f7 Merge pull request #1275 from asarium/fix/changeClassAssert
Remove unneded assert in change_ship_class
2017-03-03 15:17:47 -08:00
MageKing17 079a3f96eb Merge pull request #1276 from asarium/fix/objectSignature
Adjust object_h validity check to avoid assertion failure
2017-03-03 15:17:07 -08:00
asarium a94bf2e9e2 Skip parse tests in release mode 2017-03-03 19:58:54 +01:00
asarium 92e8db7ff4 Ignore .fuse_hidden files 2017-03-03 19:02:05 +01:00
asarium 81f5cf4446 Fix assertion failure in weapon choice screen
If the descripting of a weapon is too long it would currently cause a
very unhelpful assertion message. This fixes that by checking the length
of the lines when parsing the weapon description. I removed the
assertions since the string is just cut of if it is too long so that
fixes the actual assertion.

I also added two unit tests for making sure that too long descriptions
cause warnings.
2017-03-03 18:59:30 +01:00
asarium 842858f9b8 Adjust object_h validity check to avoid assertion failure
I found this issue while debugging the JAD gauntlet where a script calls
getSignature() on an invalid object. However, object_h does not see the
object as invalid even though its signature is 0 which is defined to be
an invalid sigature. This should fix that by making sure that
object_h::isValid returns false if the saved signature is not valid.
2017-03-03 17:46:00 +01:00
asarium 415b2b4933 Remove unneded assert in change_ship_class
I just encountered this assertion while debugging another issue. As far
as I can tell, this can happen if the ship dies the same frame that
change_ship_class is called. Since a negative hull_strength value is a
valid value this assert is invalid. The CLAMP should ensure that the
following code still behaves as expected.
2017-03-03 17:27:45 +01:00
Fabian Woltermann e243601cf0 Merge pull request #1274 from asarium/fix/generatedShieldRtt
Fix generated shields rendering in cockpits
2017-03-03 15:26:35 +01:00
asarium 808231dd7d Fix generated shields rendering in cockpits
The generated shields did not respect the display offset specified in
the table so they were drawn out of the clipping bounds of the gauge
which meant that they were not visible. This fixes that by respecting
the specified display offset when rendering the shield icons.
2017-03-03 13:18:00 +01:00
Cliff Gordon 44093bd88c Merge pull request #1273 from asarium/fix/macHighDPI
Fix rendering on high DPI displays on Mac
2017-03-02 13:09:28 -06:00
asarium 4d7324dddf Fix rendering on high DPI displays on Mac
I added the "allow high DPI windows" SDL-flag while investigating #998
but since that flag isn't used on Windows we can safely remove it again
without causing issues.
2017-03-02 16:15:53 +01:00
Fabian Woltermann 83dd78a95f Merge pull request #1271 from SamuelCho/fresnelFactor
Adjustable fresnel term in lighting model. Model shader cleanup. Deferred lighting shader fix.
2017-03-02 09:36:42 +01:00
SamuelCho d31083cabc Restore environment map attenuation following shader cleanup. 2017-03-01 21:26:50 -08:00
m!m c154581d6e Merge pull request #1269 from asarium/fix/windowsManifest
Add a Windows executable manifest to FreeSpace2
2017-03-01 09:29:07 +01:00
SamuelCho 2fd72258f4 Added adjustable fresnel term to Blinn-Phong lighting model. Cleaned up the model shader. Fixed deferred lighting shader to use correct specular material color instead of specular light color for F_0 term. 2017-02-28 22:31:52 -08:00
asarium 67051463bd Require that the energy bar animation has 4 frames
Since the rendering code always accesses all four frames it must be
ensured that they are all present. Currently, there is a bmpman
assertion about an invalid handle if the animation does not have enough
frames. This fixes that by warning about that and then resetting the
bitmap handle to -1 so that the rendering code doesn't try to use the
handle.
2017-02-28 14:30:42 +01:00
m!m 930e435ffd Add comment for clarifying Windows XP compatibility 2017-02-28 09:09:07 +01:00
asarium 6b62146388 Add a Windows executable manifest to FreeSpace2
This sets the dpiAware flag which should improve the compatibility with
High-DPI displays. It also sets a few values for specfying what Windows
versions we support and it also enabled the nicer dialog boxes which
makes the error and warning dialogs look a bit nicer.
2017-02-27 17:27:02 +01:00
Fabian Woltermann 1f648f58e5 Merge pull request #1268 from asarium/fix/msvcPCHMemory
Allocate more memory for the Visual Studio compiler
2017-02-27 12:37:16 +01:00
asarium e7fb0dacc5 Allocate more memory for the Visual Studio compiler
One of the nightly builds failed to compile with an error saying that it
had run out of heap space. This adds the suggested flag which should
hopefully fix this issue.
2017-02-27 09:48:01 +01:00
m!m 989c010a64 Merge pull request #1265 from The-E/ReplaceAllTextures
Make table-based texture replacement work
2017-02-26 23:24:38 +01:00
Fabian Woltermann 9e3f07305b Merge pull request #1260 from asarium/fix/1224
Make Skip_packfile_search restrict search to actual files
2017-02-26 15:42:04 +01:00
Fabian Woltermann 9e93ebde03 Merge pull request #1266 from asarium/cmake_/gccReturnWarning
Enable GCC and Clang warning for missing return
2017-02-26 15:40:31 +01:00
Fabian Woltermann 8774f0480d Delete the = operator as well 2017-02-26 14:03:08 +01:00
Fabian Woltermann 17b33317de Addressing feedback. This disables the copy operator for model_render_params and changes the one place where it was actually used. 2017-02-26 13:45:03 +01:00
asarium db4fbe8fd6 Enable GCC and Clang warning for missing return
The C++ standard allows to have no return in a function but in most
cases that is not the desired behavior. There are currently no instances
of this warning in our code but I encountered this error while
developing something else.
2017-02-26 12:58:19 +01:00
Fabian Woltermann 9e4c6df219 Applies table-based texture replacement settings in the lab, techroom and the weapon/ship select screens 2017-02-25 21:38:58 +01:00
Fabian Woltermann 9e50680685 Merge pull request #1262 from asarium/fix/1261
Render correct number of vertices for shield icon
2017-02-25 15:17:41 +01:00
asarium a02c2deb69 Render correct number of vertices for shield icon
I also added a few graphics debug scopes since I needed those for
tracking down which code renders the shield icons.

This fixes #1261.
2017-02-25 12:59:51 +01:00
asarium df5679c9d1 Make Skip_packfile_search restrict search to actual files
The flag was previously used to restrict searching of mission files to
the root directory of the mod. Since the SDL merge changed what the
default root directory is (now it's the mod folder in the user folder)
this broke the mission editor and it didn't show any missions anymore.

This fixes that by altering how Skip_packfile_search affects the file
search. Now that causes the search to skip files in VPs but it still
includes all other files that are present on the disk.

I also fixed some inconsistent behavior in the various file enumeration
functions since they weren't doing the same thing.

This changes the original behavior slightly since new files aren't found
in this search since the file list is only initialized when CFile is
started so if a new file is added after that, it is not reflected in the
mission list. Since that is pretty rare we can probably ignore that
here.

This fixes #1224.
2017-02-25 12:20:05 +01:00
Fabian Woltermann 12c9ba07f8 Merge pull request #1247 from asarium/fix/1244
Fix or suppress warnings in stb_image
2017-02-23 09:49:27 +01:00
Fabian Woltermann 7ef78fd17b Merge pull request #1254 from asarium/cmake_/prefixHeader
Use a manually maintained prefix header for cotire
2017-02-23 09:47:00 +01:00
asarium d7274b85f9 Use a manually maintained prefix header for cotire
Cotire (the CMake module we use for handling precompiled headers) can
auotmaically generate a prefix header by examining the includes of the
project. However, if a system include changes, the prefix header may
change as well which triggers a complete project rebuild. To avoid this
and to add the ability to customize the prefix header, I added a
manually maintaned header which will be used by all platforms and which
will only change if that file is manually changed.
2017-02-22 23:21:46 +01:00
m!m 4f9f0b6868 Merge pull request #1259 from The-E/scriptEvalCleanup
Like script-eval, script-eval-string should also return SEXP_TRUE
2017-02-22 19:41:41 +01:00
Fabian Woltermann 98169f9f2e Merge pull request #1258 from asarium/fix/playerVariableSimulation
Set the Player scripting variable for the whole frame
2017-02-22 18:29:54 +01:00
Fabian Woltermann 99e1f22d12 Like script-eval, script-eval-string should also return SEXP_TRUE 2017-02-22 17:00:57 +01:00
MageKing17 59769894f3 Merge pull request #1255 from asarium/doc/sexpCarCdr
Add documentation for CAR and CDR
2017-02-22 07:09:27 -08:00
asarium b7e46e49d3 Set the Player scripting variable for the whole frame
Otherwise the Simulation hook would be called without a Player variable
which breaks some scripts.
2017-02-22 15:42:50 +01:00
m!m d96295e923 Merge pull request #1257 from The-E/ScriptEvalReturns
Make script-eval return SEXP_TRUE
2017-02-22 13:44:03 +01:00
Fabian Woltermann 47aa9a6237 Make script-eval return SEXP_TRUE so that it behaves as expected when used in an event without a when conditional 2017-02-22 12:32:18 +01:00
asarium e374637df2 Fix or suppress warnings in stb_image
This fixes #1244.
2017-02-22 12:04:35 +01:00
asarium 8e71c392ab Add documentation for CAR and CDR
This should clear up some confusion about what the functions do since
their behavior is not obvious from looking at the code.
2017-02-22 11:28:21 +01:00
Cliff Gordon bad7254692 Merge pull request #1252 from asarium/fix/macosxBundle
Use the correct variables in MacOSX Info.plist
2017-02-21 19:52:48 -06:00
Fabian Woltermann 0af2736327 Load the Fire particle animations (#1251)
Load the Fire particle animations too. Fixes #1245.
2017-02-21 16:20:35 -08:00
asarium df01822c2a Use the correct variables in MacOSX Info.plist
This fixes #1228.
2017-02-21 21:56:45 +01:00
Fabian Woltermann 8e04c6c8e0 Merge pull request #1250 from asarium/fix/debugWindowWidth
Fix assertion in debug window when width is too low
2017-02-21 14:13:16 +01:00
asarium e71b9629fe Fix assertion in debug window when width is too low 2017-02-20 11:59:02 +01:00
Fabian Woltermann c3e3337802 Merge pull request #1235 from asarium/fix/ffmpegVersionConstraint
Add a sensible version constraint for FFmpeg
2017-02-20 09:12:24 +01:00
Fabian Woltermann f70adedfaf Merge pull request #1249 from MageKing17/bugfix/debris-ship-class-alt-name
Make debris from a ship use the ship class's alt name, if specified.
2017-02-20 09:11:52 +01:00
Fabian Woltermann 1edd6e8297 Merge pull request #1248 from MageKing17/bugfix/player-variable-reset
Clear the player's variable vector in init_new_pilot() if reset is true.
2017-02-20 09:10:56 +01:00
MageKing17 77a71f3445 Make debris from a ship use the ship class's alt name, if specified.
A piece of debris spawned from a ship will say what class of ship it came from. If that ship has an alternate class name defined in FRED, that's used instead. If the ship class table entry specifies an "$Alt name:", however, that isn't used, which could potentially be confusing. This fixes that oversight.
2017-02-19 14:56:53 -08:00
MageKing17 0b6a8c11f6 Clear the player's variable vector in init_new_pilot() if reset is true.
This fixes a bug whereby creating a pilot in the barracks screen (not the initial pilot selection screen) would effectively clone the variable vector from whatever pilot was selected beforehand.
2017-02-19 14:54:01 -08:00
Fabian Woltermann 08f80fe190 Merge pull request #1234 from asarium/fix/mantis3183
Render all damage elements of the damage HUD gauge
2017-02-19 00:08:23 +01:00
m!m fe8ead6609 Merge pull request #1240 from vazor222/bugfix/addSubmoduleNoteToReadme
minor readme updates
2017-02-18 22:34:24 +01:00
niffiwan df8f20f208 Merge pull request #1242 from asarium/fix/1241
Copy all relevant values in the LuaFunction copy-constructor
2017-02-19 07:33:56 +10:00
asarium 5bf2b956f6 Copy all relevant values in the LuaFunction copy-constructor
This fixes #1241.
2017-02-18 19:33:44 +01:00
vazor e218c3967e formatting update 2017-02-18 11:01:57 -07:00
z64555 d68370ade7 Merge pull request #1239 from asarium/fix/timeroverflow
Fix standalone timer overflow
2017-02-18 11:57:38 -06:00
vazor 8c79033819 added note to readme that would have saved me some time, minor typo fix 2017-02-18 10:46:32 -07:00
asarium 15af2bb1a2 Fix standalone timer overflow
If FSO runs for a very long time (5 hours to be exact) then the SDL
performance counter reaches a value so hight that rescaling it to
microseconds causes an overflow which is bad.

This fixes that by implementing the rescaling by computing the factor in
the timer initialization code and then multiplying the SDL time with
that. This uses the same principle as the changes done by @TheMatthew in #1082.

According to the tests done by @chief1983, this fixes #1237.
2017-02-18 16:54:58 +01:00
Cliff Gordon 82d8f5df74 Merge pull request #1236 from asarium/cmake_/formatDefinition
Always define __STDC_FORMAT_MACROS for GCC and Clang
2017-02-17 12:23:16 -06:00
m!m cb12cbef45 Merge pull request #1233 from The-E/CfileToolsCmakeFix
Cfile tools cmake fix
2017-02-17 13:59:47 +01:00
MageKing17 b8a9c520f3 Merge pull request #1226 from asarium/fix/briefingWrapping
Fix briefing word wrapping when a script changes the font
2017-02-17 02:31:15 -08:00
m!m bffe4b787d Merge pull request #1223 from Yarn366/fred_max_missile_count
Change get_max_ammo_count_for_bank to return "correct" max missile count
2017-02-17 10:46:17 +01:00
asarium 76db58932e Always define __STDC_FORMAT_MACROS for GCC and Clang
This caused some issues for @chief1983 when trying to compile on an
older Linux distribution.
2017-02-16 19:41:55 +01:00
asarium 7f73d35753 Add a sensible version constraint for FFmpeg
2.7 is the last version we can support with our current code so we
should check for that.
2017-02-16 19:16:56 +01:00
Fabian Woltermann cd5e276102 Changes the usage printout as per discussion 2017-02-16 10:24:51 +01:00
asarium 900218e3e4 Render all damage elements of the damage HUD gauge
Previously, the hud gauge was hidden if the player ship had taken no
damage. However, this made it impossible to see if subsystems have been
damaged.

These changes make sure that the subsystem values are shown even if the
hull integrity is at 100%. This is done by first collecting all the
necessary information about each line in the gauge and then, if that list
is non-empty, rendering it. This is necessary since the gauge code can't
decide if anything will be visible before looking at the entire
subsystem list.

There is a minor behavior change with how popups are handled.
Previously, the code would return if the HUD gauge was a popup and its
strength was at 100%. However, I think that this was dead code anyway
since that condition could never be true at that point because the code
would have returned earlier if there was no damage.

This fixes Mantis 3183.
2017-02-15 19:29:09 +01:00
Fabian Woltermann af285fbdbd Merge pull request #1232 from asarium/fix/mantis3177
Unload models after loading them for -pofspew
2017-02-15 16:28:16 +01:00
Fabian Woltermann d78a9fe8e3 Removes unnecessary stuff from the commandline help for cfilearchiver 2017-02-15 16:13:00 +01:00
Fabian Woltermann 792cbf20a9 Fixes Configuration error for the CFileArchiver/Extractor projects 2017-02-15 16:12:59 +01:00
asarium 0641437803 Unload models after loading them for -pofspew
In large mods this caused memory issues since we reached the 32-bit
memory limit when loading all models of a large mod (e.g. Blue Planet).

I fixed that by explicitly unloading the loaded model once the code is
done with it.

This fixes Mantis 3177.
2017-02-15 10:29:03 +01:00
Fabian Woltermann fa5db4fcfa Merge pull request #1230 from asarium/fix/mantis3175
Fix "On Object Render" behavior regression
2017-02-15 10:06:39 +01:00
m!m bea4c628ec Merge pull request #1231 from jg18/xcode_debug_symbols
Configure Xcode projects to generate debug symbols for Debug builds.
2017-02-15 09:45:07 +01:00
jg18 11e2491124 Configure Xcode projects to generate .dSYM file. 2017-02-14 21:33:58 -08:00
jg18 09021f3141 Configure Xcode projects to generate debug symbols for Debug builds.
Set CMake to configure Xcode projects to generate debug symbols for Debug builds.
2017-02-14 21:05:54 -08:00
asarium bd4b845290 Fix "On Object Render" behavior regression
This regression was introduced with the new model draw list which separates
collecting the drawing information and actually drawing the objects.

Previously, the scripting hook was always executed and the override
condition was used to determine if the normal rendering should happen.
Since 3.7.4, the scripting code is only executed if the condition was
overridden by Lua and if that override is active then the model isn't
rendered at all.

This executes the scripting hook in all cases and then checks if the
scripting system specified if rendering of that object should be
skipped. This introduces some slight changes in behavior since, when the
scripting hook is executed, the object isn't actually being rendered but
instead it's added to the draw list. IMO, that is not a major issue for
any existing application or else we would have heard about that until
now.

This fixes Mantis 3175.
2017-02-14 20:11:04 +01:00
Fabian Woltermann e0e7f141ad Merge pull request #1229 from asarium/fix/mantis3188
Fix wrong control flow in stars_draw_sun
2017-02-14 17:28:14 +01:00
Fabian Woltermann 7bdaac55e5 Merge pull request #1225 from asarium/fix/cfileTests
Actually add CFile to the unit test project
2017-02-14 15:06:21 +01:00
asarium c473601875 Fix wrong control flow in stars_draw_sun
The code wrongly used return instead of continue. This caused a second
sun to disappear if the bitmap of the first sun wasn't drawn.

This fixes Mantis 3188.
2017-02-14 14:54:46 +01:00
m!m bd0a1440e7 Merge pull request #1227 from chief1983/fix/967
Fix for #967 - Enable APPLE_APP in Mac CMake project
2017-02-14 11:00:24 +01:00
asarium 6508f47625 Fix briefing word wrapping when a script changes the font
This happened in BtA where a script changed the font after rendering its
UI. Since the briefing code didn't account for that, the word wrapping
code used the wrong font for calculating how long a line would be which
made the display look wrong.
2017-02-14 10:37:55 +01:00
Cliff Gordon 05a12213de fix/967: Define APPLE_APP to fix some issues introduced on Mac in the CMake conversion (may have other effects we aren't yet aware of). 2017-02-13 13:09:36 -06:00
asarium e90563c437 Actually add CFile to the unit test project
For some reason these weren't included in the PR that was supposed to
contain them.
2017-02-13 14:52:09 +01:00
m!m 7e8005033d Merge pull request #1222 from Yarn366/fred_retail_red_alert
Fix for improper setting of +Red Alert:
2017-02-13 10:07:51 +01:00
Yarn366 6be290ed8b Change get_max_ammo_count_for_bank to return what the rest of the game considers to be the max missile count 2017-02-13 00:00:27 -05:00
Yarn366 82735a0cfd In retail mode, set +Red Alert: according to the Red_alert flag rather than the Fullneb flag 2017-02-12 23:26:53 -05:00
m!m 5f5dbf5139 Merge pull request #1220 from The-E/ExportNoEmissive
Export the -no_emissive_light flag to the Launcher
2017-02-13 00:07:24 +01:00
Fabian Woltermann be3f86cd65 Export the -no_emissive_light flag to the Launcher 2017-02-12 22:17:53 +01:00
Fabian Woltermann 3df8b53570 Merge pull request #1219 from PeterMitsis/parallel-fix
vecmat: Fix vm_test_parallel()
2017-02-12 18:30:21 +01:00
MageKing17 8eafa260d2 Merge pull request #1218 from The-E/RotationWarningFix
Removes log spam
2017-02-12 09:18:21 -08:00
Fabian Woltermann ea5342bc70 Merge pull request #1216 from asarium/fix/1051
Create main window at 0,0 if its the same size as the display
2017-02-12 17:38:04 +01:00
Fabian Woltermann 8ffb0fe407 When converting an Assertion to a Warning or log print, remember to invert the Assertion's condition to get correct behaviour 2017-02-12 17:26:11 +01:00
Peter Mitsis f448150156 vecmat: Fix vm_test_parallel()
Fixes a subtle problem with vm_test_parallel() wherein a relative error
was accidentally converted into an absolute error.

Instead of comparing the result of the cross product to the zero vector,
the two calculated components of the cross product are compared against
each other. This permits vectors whose cross product is a large number
but whose cross product partials are within relative error of each other
to be treated as parallel.

For example, the following two vectors may now be considered as parallel
whereas before they were not:
   v1 = (1000004.0, 1.0, 1.0)
   v2 = (1000000.0, 1.0, 1.0)
The relative difference between them is sufficiently small according to
vm_vec_equal() for them to be considered equal, but their cross product
would have elements whose magnitudes would be near 4.0 which would
otherwise indicate that they are not parallel. By comparing the partials
instead, a higher degree of consistency is maintained.

Signed-off-by: Peter Mitsis <[email protected]>
2017-02-12 11:04:38 -05:00
asarium 6c1d5263f1 Create main window at 0,0 if its the same size as the display
This fixes #1051 by explicity telling SDL to create the window in the
display corner instead of centering the window. This has caused some
problems because the window borders aren't visible anymore in this case
which lead to some confusion.
2017-02-12 15:42:19 +01:00
m!m 58b49486ce Merge pull request #1215 from Goober5000/issue_1176_bugfix
make sure we find the correct operator for logging in short-circuited sexps
2017-02-12 10:36:29 +01:00
Goober5000 b2a2c7b0bd make sure we find the correct operator for logging in short-circuited sexps 2017-02-12 00:50:11 -05:00
niffiwan df6b2d4cdd Merge pull request #1214 from asarium/fix/btaSystemMapNodes
Return correct bits-per-pixel data for 16-bit PNGs
2017-02-12 11:02:27 +10:00
asarium 6f84fcbf6d Return correct bits-per-pixel data for 16-bit PNGs
PNGs can have 16 bits per channel but we always tell libpng to reduce
that to 8 bits per channel. However, we do not tell the caller of
png_read_header that this will happen so instead of 32-bits per pixel,
we tell bmpman that the image has 64 bits per pixel which causes some
issues.

The specific issue I fixed was the system map of BtA where the jump
nodes used a 16-bit PNG which broke the alpha blending of those bitmaps
since bmpan though that the image had no alpha channel.
2017-02-11 23:24:09 +01:00
Fabian Woltermann 028ae98c21 Merge pull request #1212 from TRBlount/Lab_initial_orient
Change Initial Orientation in the Lab
2017-02-11 21:25:53 +01:00
TRBlount f4d11325c6 Change Initial Orientation in the Lab 2017-02-11 10:39:12 -07:00
m!m 2b83c73f8f Merge pull request #1213 from Yarn366/weapons_dialog_rounding
Fix for rounding errors in weapons dialog
2017-02-11 11:43:50 +01:00
Yarn366 39e1ae18a4 Added proper rounding to missile counts in the weapons dialog. 2017-02-10 20:23:10 -05:00
m!m eb1389d738 Merge pull request #1208 from The-E/LikeARecordBabyRightRound
Changes the "Object rotated too far" assertion to a log message
2017-02-09 15:48:13 +01:00
Fabian Woltermann 589eb7533c Merge pull request #1195 from asarium/opengl/moreObjectLabels
Assign OpenGL labels to more objects
2017-02-09 12:41:52 +01:00
Fabian Woltermann fbe9cc156c Merge pull request #1204 from asarium/fix/1182
Search for path types regardless of case
2017-02-09 12:40:36 +01:00
Fabian Woltermann b319143a67 Changes the "Object rotated too far" assertion to a log message, as per discussion for PR #1171 2017-02-09 12:35:23 +01:00
m!m d71a6b0ba7 Merge pull request #1175 from MageKing17/bugfix/energy-transfer-oddities
Fix two bugs with transferring energy to/from shields/weapons.
2017-02-09 10:11:11 +01:00
z64555 5d7b64fcbf Merge pull request #1207 from z64555/fix/vec_parallel
Fix minor bug with parallel vector testing
2017-02-08 23:16:17 -06:00
z64555 39912e025b Use vm_vec_equal, like you intended. 2017-02-08 18:38:56 -06:00
MageKing17 4a3f9f1d84 Merge pull request #1203 from asarium/ci/fixNightlyBuilds
Fix wrong variable usage in test script
2017-02-08 12:56:20 -08:00
z64555 8195fd50ab Fix minor bug with parallel vector testing 2017-02-08 12:42:59 -06:00
Goober5000 a64468200e Merge pull request #1200 from chief1983/fix/dircreate
Stops debug log printing "Creating new directory"
2017-02-08 13:39:17 -05:00
asarium 6ff7662c29 Search for path types regarless of case
Previously, if a mod used an upper case "Data" folder (which is the case
for the Diaspora development files) the file enumeration would fail on
case sensitive platforms (e.g. Linux) since FSO searched for a path with
a lower case "data". These changes make it so that FSO looks for all
instances of the path type name regeardless of case. Since the real path
was also needed elsewhere I added a new cf_file field which stores the
actual path which can then be used by fopen operations.

This fixes #1182.
2017-02-08 19:17:33 +01:00
Cliff Gordon d3480f70f2 Fix for log printing creating directory lines for directories that already exist. 2017-02-08 10:35:36 -06:00
Fabian Woltermann 2907c7ab94 Merge pull request #1197 from asarium/fix/712
Boost the color of nebula bitmaps to make them visible again
2017-02-08 14:19:50 +01:00
Fabian Woltermann 1a130c794a Merge pull request #1199 from asarium/fix/highestObjectCrash
Fix negative array index
2017-02-08 14:18:58 +01:00
asarium c589c72817 Fix wrong variable usage in test script 2017-02-08 13:08:50 +01:00
Fabian Woltermann 695bee61c8 Merge pull request #1201 from asarium/fix/643
Remove object instance from lab render info
2017-02-08 12:33:16 +01:00
Fabian Woltermann 7c8abe0f16 Merge pull request #1202 from scp-fs2open/revert-1187-fix/1182_2
Revert "Show error message when a data directory uses the wrong case"
2017-02-08 12:32:41 +01:00
m!m 07c86cd9c8 Revert "Show error message when a data directory uses the wrong case" 2017-02-08 10:52:46 +01:00
asarium cb531f8a88 Remove object instance from lab render info
If the object number is set for the render info the renderer uses the
instance information of that object to render the model. That is not
correct for the lab since the instance data is handled by the lab code
in that case.

This fixes #643.
2017-02-07 22:37:38 +01:00
MageKing17 86cb91f9f2 Merge pull request #1194 from asarium/unittests/appveyor
Execute unit tests on appveyor
2017-02-07 12:57:49 -08:00
asarium f87a72bc15 Fix negative array index
If there was only one object and that got deleted the code that keeps
track of the highest object index would cause a negativ array index. I
added a check to make sure that the index was positive but that still
means that Highest_object_index will be negativ after that function
returns. I looked at the usages of the value and that value seems to be
fine with that code so I think this should be safe.
2017-02-07 19:55:27 +01:00
asarium 33496419f9 Boost the color of nebula bitmaps to make them visible again
The HDR changes made the nebula bitmaps a lot less visible. This fixes
that by boosting the color of the bitmaps when they are rendered.

I choose 3 since that gives a similar look to 3.7.4 but that can be
further tweaked if desired.

I also added two debug scopes to help track down where that stuff was
actually rendered.

This fixes #712.
2017-02-07 18:33:15 +01:00
Fabian Woltermann 4321fd364d Merge pull request #1187 from asarium/fix/1182_2
Show error message when a data directory uses the wrong case
2017-02-07 17:34:03 +01:00
Fabian Woltermann d40cf7a3cd Merge pull request #1179 from asarium/fix/651
Make sure that team glow colors don't go negativ
2017-02-07 17:33:25 +01:00
Fabian Woltermann fa90542b00 Merge pull request #1193 from asarium/fix/611
Disable resizing for cubemaps
2017-02-07 17:32:56 +01:00
asarium cdc6f7d907 Disable lua args tests since MSVC 2013 doesn't like them
The code the test was testing isn't used by anyway so we don't loose
test coverage. I'm also quite certain that the failure is caused by some
sort of compiler bug or wrong standard library implementation.
2017-02-07 17:09:39 +01:00
asarium 084d237437 Assign OpenGL labels to more objects
The texture labels make it easier to debug which texture is currently
bound when tracing with APItrace.
2017-02-07 16:30:21 +01:00
asarium 62f6494299 Execute unit tests on appveyor
Appveyor didn't have the OpenAL DLLs so I included those with our
existing files. They are currently not used by FreeSpace or FRED.
2017-02-07 14:50:37 +01:00
Fabian Woltermann 19583bc788 Merge pull request #1192 from asarium/fix/1191
Restore original flag parsing behavior
2017-02-07 06:11:07 +01:00
asarium fff62a85e0 Restore original flag parsing behavior
THe flagset changes misplaced the post-parsing flag processing so that
it was only executed if a special flag was found. That was not the case
previously and this restores that behavior. I also simplified the code a
bit while I was at it.

This fixes #1191.
2017-02-06 22:37:15 +01:00
asarium e52b144510 Disable resizing for cubemaps
Since the cubmap loading code explicitly states that it doesn't support
resizing it's only logical to skip that if the bitmap that is currently
being loaded is a cube map.

This fixes #611.
2017-02-06 18:42:06 +01:00
Fabian Woltermann e8d21a020f Merge pull request #1189 from asarium/fix/940
Set the registry key for FRED
2017-02-06 09:32:39 +01:00
Fabian Woltermann 8b24877f9e Merge pull request #1190 from asarium/fix/bloomAccumulator
Fix post processing framebuffer binding
2017-02-05 18:45:41 +01:00
Fabian Woltermann 6efceb2017 Merge pull request #1188 from asarium/fix/objectLabelCrash
Fix crash when using glObjectLabel
2017-02-05 17:19:37 +01:00
asarium c28bfcf959 Fix post processing framebuffer binding
The framebuffer stack operations were at the wrong locations which
caused problems since the wrong buffers were used for rendering.
2017-02-05 17:17:33 +01:00
asarium 0b472ea463 Set the registry key for FRED
The default key is probably not valid anymore since we don't use the
registry virtualization anymore.

This fixes #940.
2017-02-05 17:02:44 +01:00
asarium ec82cb15ce Fix cmpilation errors 2017-02-05 15:44:13 +01:00
asarium 69dba707e0 Fix crash when using glObjectLabel
Apparently OpenGL contexts aren't supposed to expose the KHR variant so
this version should work better if the extension is supported.
2017-02-05 15:40:40 +01:00
Fabian Woltermann f50be50b18 Merge pull request #1173 from asarium/cleanup/tcache
Remove tcache_set from rendering API
2017-02-05 15:28:29 +01:00
Fabian Woltermann 90a5af60c4 Merge pull request #1186 from asarium/fix/976
Fix wrong usage of cockpit depth buffer
2017-02-05 15:26:15 +01:00
asarium 33c1b788df Clean up Unix code a bit 2017-02-05 14:46:16 +01:00
asarium 5265627b8f Add case check for Windows 2017-02-05 14:43:58 +01:00
asarium 94ce0ad2dd Add test for wrong case in data directory 2017-02-05 13:06:01 +01:00
asarium 0eeb895432 Issue error when a data directory uses the wrong case
Since Unix is case senssitive this should make sure that case errors are
cought early in mod development. This is an Error and not a Warning
since a mod with such a folder structure would never work under Unix and
as such it's justified to break mods that currently use this.
2017-02-05 13:03:57 +01:00
asarium 5d7f10d4f8 Add utility function for assigning labels to OpenGL objects 2017-02-05 12:06:37 +01:00
asarium 9013d398db Fix wrong usage of cockpit depth buffer
The root issue of #976 was that the code that reset the depth buffer of
the scene framebuffer was actually setting the depth buffer of the bloom
framebuffer since that didn't get reset properly. To fix this I
introduced a system in our GL_state which keeps track of a stack of
"bound" framebuffers which allows us to return to the previous
framebuffer with a simple function call.

I also added support for GL_KHR_debug since that help me while debugging
which texture was in use. In the future I'll probably extend that to
other areas of the OpenGL code as needed.

This fixes #976.
2017-02-05 12:03:26 +01:00
asarium 7c556854af Add more graphics debug scopes for code called in the main frame 2017-02-05 12:03:23 +01:00
MageKing17 ce519f006d Merge pull request #1185 from z64555/fix/github_1177
Fixes pointer access violation when docked ships warp out by moving dock_undock_all call to red_alert_delete.

It was previously thought that dock_undock_all() was supposed to be within ship_cleanup() and was safe to do so. Nope.

dock_evaluate_all_docked_objects makes the assumption that the dock_list is still valid, so if the function called by it happens to nuke the dock_list (like with ship_cleanup) then it'll work with invalid pointer values.
2017-02-04 22:37:28 -08:00
z64555 4129551341 Fixes pointer access violation when docked ships warp out by moving dock_undock_all call to red_alert_delete.
It was previously thought that dock_undock_all() was supposed to be within ship_cleanup() and was safe to do so. Nope.

dock_evaluate_all_docked_objects makes the assumption that the dock_list is still valid, so if the function called by it happens to nuke the dock_list (like with ship_cleanup) then it'll work with invalid pointer values.
2017-02-04 22:12:14 -06:00
niffiwan 9be888f55a Merge pull request #1183 from asarium/fix/newVMFree
Fix new/vm_free mismatch reported by AddressSanitizer
2017-02-05 09:21:14 +10:00
m!m b185d1bfea Merge pull request #1178 from The-E/VS2017ignores
Updates the gitignore for VS2017
2017-02-05 00:09:46 +01:00
MageKing17 19a37eb04d Merge pull request #1024 from asarium/feature/defaultConfigLoc
Improve logic for determining legacy mode
2017-02-04 11:33:45 -08:00
asarium ca2f9b788f Fix new/vm_free mismatch reported by AddressSanitizer 2017-02-04 19:12:34 +01:00
Fabian Woltermann 9a1eb4e794 Update .gitignore
Removes duplicate entry
2017-02-04 13:38:01 +01:00
m!m 592282448b Merge pull request #1180 from niffiwan/coverity/1370830
Fix Coverity 1370830
2017-02-04 10:15:59 +01:00
niffiwan e6bff4f864 Fix Coverity 1370830
Use after free; use the copied string for the Warning
2017-02-04 16:16:18 +10:00
asarium 1cf0bacc6e Make sure that team glow colors don't go negativ 2017-02-03 22:30:39 +01:00
Fabian Woltermann 1f352967c7 Updates the gitignore for files that VS2017 writes when opening the repository 2017-02-03 15:49:20 +01:00
MageKing17 cf14728757 Avoid silly behavior when transferring almost-nonexistent energy.
This is a bit complicated to explain, so stick with me.

When transferring energy from shields to weapons (or vice versa), the values modified are the so-called "target deltas" rather than directly modifying the shield strength or weapon energy values. The ship_chase_shield_energy_targets() function carries out actually meeting these targets without exceeding a change of ETS_RECHARGE_RATE percent per second. At least, that's what it's supposed to do, and obviously works that way when the target delta is positive.

When the target delta is negative, however, a logic error with the conditional meant to limit the rate of change instead functions backwards; if the amount of desired change exceeds the per-frame limit, the amount of change is set to the total desired change, and if the amount of desired change is smaller than the per-frame limit, than the amount of change is the per-frame limit (even though that's more than the amount that's supposed to be drained).

Since the target delta is modified by the amount by which the value changed, this leads to an interesting consequence whereby the "extra" amount taken away is added back in the next frame... which has another interesting side-effect if the "extra" drain tried to reduce shields below 0. Namely, the shield code doesn't let it, while ship_chase_shield_energy_targets() remains blissfully unaware that the actual change was smaller than requested. So on the next frame, you spontaneously get some fraction of a percent of your shields back. Which, naturally, you can then transfer energy from to your weapons ad infinitum; the amount is small, but you can continually transfer it, so you're getting weapon energy out of nowhere.

Now, straight-up fixing the logic error would be a major retail balance change; if transferring energy from your shields to your weapons only gradually reduced your shields, instead of taking a huge chunk at the start, it would be a much safer option. Therefore, the only non-balance-changing fix is to just remove the broken conditional entirely (so that it always drains the full amount instantaneously, regardless of how big or small it is).

I've left the fixed conditional commented out so that somebody, when we're not in a feature freeze, can add an AI profile or mod table flag to restore the check, allowing for slow energy transfers.
2017-02-03 02:26:34 -08:00
MageKing17 c5278e2e95 Allow transferring energy from shields to work properly at full shields.
A conditional originally added to shield_add_strength() to make shields not recharge beyond the recharge limit forgot to check that the amount shields are changing by was positive (unlike a couple other conditionals added/modified around the same time), so a call to shield_add_strength() with a negative delta (e.g. when transferring energy from shields to weapons) when the current shield strength is at or above the recharge limit (i.e. full strength when a recharge limit isn't specified) would immediately return without doing anything. This would, of course, result in no change to shield strength... so if you had full shields and had drained your weapon batteries dry, you could get free energy by hitting the button to transfer energy from your shields.
2017-02-03 02:05:51 -08:00
MageKing17 fe1e9ca996 Merge pull request #1174 from asarium/cleanup/GLSL_version
Remove some unneeded OpenGL version checks
2017-02-03 01:55:31 -08:00
asarium 4ed9231983 Simplify condition 2017-02-02 23:25:50 +01:00
asarium ca1a844f08 Remove GL_version checks that are always true
Same as the GLSL version checks, these conditions were always true since
we only support OpenGL 3.2 now.

There was also an assertion condition that didn't make sense so I fixed
that.
2017-02-02 22:38:31 +01:00
asarium 833df59d0e Remove GLSL version checks that are always true
These checks were from a time when we supported lower OpenGL version
than 3.2. Since we don't do that anymore and show an error if the
drivers don't support that, these conditions always evaluated to true
and could be removed.
2017-02-02 22:35:03 +01:00
asarium 7cb652b5d2 Remove tcache_set from rendering API
It wasn't used anywhere and has been superseded by the material system.
It would also interfere with a possible texture array usage.
2017-02-02 22:26:14 +01:00
MageKing17 cd06284f50 Merge pull request #1172 from The-E/MoreTraceScopes
Adds more trace scopes
2017-02-02 10:04:08 -08:00
MageKing17 1305f1dbe2 Merge pull request #1170 from The-E/PaletteCleanup
Removes the Palette Manager
2017-02-02 10:03:51 -08:00
Fabian Woltermann b3a8824d68 Adds more trace scopes to get a better look at the internals of render_frame 2017-02-02 15:07:43 +01:00
Fabian Woltermann b42fb8272a Removes code that had been #ifdefed out 2017-02-02 13:16:28 +01:00
z64555 36c134fcb8 Merge pull request #1154 from z64555/cleanup/dock_swabber
Fixes two crashes in red-alert missions, cleans up and refactors some of the docking code
2017-02-02 00:18:34 -06:00
z64555 d648091de4 Merge pull request #1168 from MageKing17/bugfix/ship_weapon-constructor
Add missing variable to ship_weapon constructor.
2017-02-02 00:18:17 -06:00
z64555 2829c293df Merge pull request #1166 from z64555/fix/pr_1163_amend
Harmony to 1163's malady
2017-02-01 21:28:20 -06:00
MageKing17 094d117764 Merge pull request #1167 from asarium/fix/autoaimSpeed
Use the correct pointer in vm_vector_2_matrix
2017-02-01 18:19:59 -08:00
Fabian Woltermann 0c0f7b9986 Removes unused variable 2017-02-01 19:58:58 +01:00
z64555 f30f955058 Update doxy on ship_cleanup to reference the object cleanup path 2017-02-01 12:58:26 -06:00
Fabian Woltermann 38e803c3c3 Restores accidentally deleted assertion from aicode 2017-02-01 19:04:09 +01:00
Fabian Woltermann 2c4c337907 Removes the palette code entirely. 2017-02-01 18:57:52 +01:00
Fabian Woltermann 7a1c587a9c Remove palette manager 2017-02-01 18:29:18 +01:00
MageKing17 8c59d8fb6d Add missing variable to ship_weapon constructor.
secondary_animation_position wasn't being set by the ship_weapon constructor, which could cause potential issues with whatever uninitialized data it wound up being set to (like, say, being unable to fire any weapons in the second secondary bank until you've cycled through it once). Since it depended on uninitialized data, the behavior could even change between 32-bit and 64-bit builds (and Release/Debug, of course).

While I was at it, I also noticed some variables were getting set twice; in one instance (primary_animation_done_time), it was even being set to the wrong value the second time (according to the pre-flagset code that used memset() on it and then overrode some values that shouldn't have been zero). Not sure what problems that could've caused; possibly some issues with animations and primary weapons, I guess, if the "done" timestamp was invalid when it shouldn't have been.
2017-02-01 02:49:57 -08:00
asarium 1623d39eea Use the correct pointer in vm_vector_2_matrix
This probably caused a lot of issues throughout the code. I fixed the
autoaim issue that happened in the capship command mission by JSRNerdo.
2017-02-01 09:36:00 +01:00
z64555 73504f80a5 Treat cleanup_mode as enumeration
*Use Assertions instead of the clunky Error/Warning pairs.
2017-02-01 01:36:16 -06:00
z64555 95315d7f8a Optimizes dock_undock_objects() and dock_dead_undock_objects() methods by removing their dock pair check, because the same check is done in the remove_instance subroutines.
* Adds a warning for debug users when an unknown ship_state is passed to red_alert_delete.
* Removes commented-out code
* Doxy's ship_cleanup()

*Conform to each file's style.

*Extend ship_cleanup to better handle red-alert deletion.
*Also treat cleanup_mode as a flagset, instead of an enum as it was previously.
2017-02-01 01:35:45 -06:00
z64555 6577d53df8 Fixes red-alert missions where escorted ships were dead or otherwise not carried into the red-alert mission.
*Use existing methods to determine dock status and find the head of the dock list.
*Fixes a derp with dock_dead_undock_all()
*Doccument some docking methods in object.h
*Address requested changes.
2017-02-01 01:35:09 -06:00
z64555 63e44beb9c When deleting an object in red-alert missions, undock all objects docked with it. 2017-02-01 01:34:29 -06:00
z64555 944ed03553 Added undock_all routines. Added asserts to public methods. 2017-02-01 01:34:29 -06:00
z64555 a5a927dd71 Get that other weapons assignment, while we're still thinking about it 2017-01-31 16:36:06 -06:00
z64555 4153aa80a9 Harmony to 1163's malady
* Looks like a shallow copy wasn't enough, so this fix creates ship_weapons::clear() which is called by ship_weapons's constructor and by ship::clear().
2017-01-31 12:04:32 -06:00
Goober5000 2a574ef267 some riffs on PR #806 (#1163)
In ship::clear(), The E removed

memset(&weapons, 0, sizeof(ship_weapon));

but did not add a corresponding

weapons = ship_weapon();

This fixes that.  Additionally, this PR removes one of the two uses of ship::clear() by tweaking hud_observer_init.  Originally, the code used memcpy, but if the assignment operator works for ai_info, it should be suitable for ship too.
2017-01-29 21:58:15 -08:00
m!m 1767b7a87b Merge pull request #1164 from z64555/cleanup/doxy_vecmat
Doxy vm_vector_2_matrix functions.
2017-01-29 23:39:49 +01:00
z64555 db3e2ae183 Doxy vm_vector_2_matrix functions.
*Enforce if-else block style within vecmat.cpp.
2017-01-29 15:35:02 -06:00
z64555 340b8d3136 Merge pull request #1158 from asarium/fix/shipSelectNullVector
Fix null vector normalization in ship select screen
2017-01-29 15:09:54 -06:00
m!m 39649e9e11 Merge pull request #1156 from MageKing17/cleanup/demo-compatibility
Improves FSO's compatibility with the FS2 Demo data
2017-01-28 20:11:16 +01:00
MageKing17 6bc1e1c3d9 Merge pull request #1161 from asarium/fix/653
Fix double rendering of effect ships
2017-01-26 18:31:28 -08:00
asarium 2997633d0d Fix double rendering of effect ships
This fixes #653.
2017-01-27 00:03:28 +01:00
m!m e0cf1301fa Merge pull request #1160 from chief1983/libupgrade/libpng_1_6_28
libupgrade/libpng_1_6_28: Upgrade libpng to 1.6.28.
2017-01-26 11:11:35 +01:00
m!m ed15b7e551 Merge pull request #1159 from chief1983/libupgrade/zlib_1_2_11
libupgrade/zlib_1_2_11: Update bundled zlib version to 1.2.11.
2017-01-26 11:08:38 +01:00
Cliff Gordon 863604d3a5 libupgrade/libpng_1_6_28: Upgrade libpng to 1.6.28. Fixes several published security vulnerabilities in most older versions. 2017-01-25 16:59:40 -06:00
Cliff Gordon f750a43b87 libupgrade/zlib_1_2_11: Update bundled zlib version to 1.2.11. Fixes a warning in inflate.c on latest clang. See issue #1103. 2017-01-25 16:47:45 -06:00
asarium b13ee73546 Fix null vector normalization in ship select screen
vm_vector_2_matrix was improperly guarded against bad parameters. In the
case I encountered the uvec was the negative of fvec which produced a
null vector when the cross product of the two vector was constructed.

These changes should fix that bug by ignoring the uvec parameter. Since
vm_vector_2_matrix and vm_vector_2_matrix_norm are basically the same, I
converted the former into an alias of the latter and only fixed that
code.
2017-01-25 19:57:07 +01:00
MageKing17 377751ab28 Avoid crashing if certain interface artwork is missing.
Changes a few windows (tech room, campaign room, medal case, and HUD config menu) to issue Warnings instead of Errors if certain pieces of interface art are missing. If their mask bitmap is missing, they automatically close themselves and display the old "Sorry, this feature is available only in the retail version" popup from the demo, allowing FSO to run the demo data without crashing when you click on the wrong button.

It also restores the special demo popup for the campaign room, which allows you to at least restart the demo campaign without deleting and recreating your pilot.
2017-01-24 13:18:42 -08:00
MageKing17 e1d3677f58 Fix bitmap release ordering mistake in medals.cpp.
Initialization of the medal window locks the mask twice (once directly and once indirectly, through set_mask_bmap()), then closing the medal window tries to release it after only unlocking it once. bm_release() will refuse to do anything if the BMPMAN entry is still locked, though, so the first release therefore does nothing, and since it will then only be released once (indirectly, by Medals_window.destroy()) after being loaded twice, the mask stays loaded in memory until FSO exits. By moving the release until after Medals_window is destroyed, the mask should be successfully released when the medals window closes.
2017-01-24 12:03:06 -08:00
MageKing17 559b07da63 Change check for 1024x768 interface art to not check 2_TechShipData-m.
The demo doesn't include techroom art because the demo doesn't have a techroom (or a campaign room, or a HUD config menu), but it still otherwise works with the higher-resolution interface.
2017-01-24 12:03:06 -08:00
MageKing17 b91e3c6ab1 Remove unhelpful assertions from comp_training_lines_by_born_on_date().
If an event with a directive contains both an is-destroyed/is-destroyed-delay for a wing with multiple waves AND the event's Sexp_useful_number is 0 (either the event contains an "is-event-*" SEXP (or one of the "-delay" ones with the optional third argument not set), and that SEXP didn't return true, or some part of the event evaluated to SEXP_CANT_EVAL) AND the wing currently has 0 ships in the mission (so Directive_count gets set to DIRECTIVE_WING_ZERO to mark the directive as being "temporarily" true, until the next wave arrives), then the directive winds up in the list of displayed directives without actually having a born_on_date set, so it fails this assertion. Since this is caused by the data supplied (in the mission) rather than a coding mistake, and since this assertion doesn't actually seem to be guarding against anything (because nothing bad happens if the comparison happens anyway, just with a born_on_date of 0), and it behaves just fine in Release builds where the assertion isn't checked, the simplest solution would seem to be to just remove the assertions altogether.

Found this issue while testing with demo data, so blame whatever Canadian wrote the first demo mission to make the "Destroy Libra" event check for either Libra being destroyed OR an event (that can't ever become true until after at least one wave of Libra gets destroyed) becoming true.
2017-01-24 12:03:06 -08:00
MageKing17 7767fdd933 Make bm_unload() check for a handle of -1.
Somewhat related to the previous commit: if, in the future, we have another instance of trying to unload a nonexistent graphic, it would make much more sense if BMPMAN returned -1 (like it already does for other failure conditions, like trying to unload an unused slot) rather than tripping the "n >= 0" assertion down below (calling with -2 or other negative values that can still trip that assertion unaccounted for, because those would definitely be mistakes in the code).
2017-01-24 12:03:06 -08:00
MageKing17 0bd8754064 Don't try to do anything with a nonexistent Fade_anim.
If Fade_anim.first_frame was -1 (like, for instance, if the animation did not exist, which it doesn't in the demo data), the briefing code would still try to do stuff with it, and then unload it when it closed. This seems like a bad idea in general.
2017-01-24 12:03:06 -08:00
MageKing17 bedfc47273 Make "+Music:" optional in mainhalls.
It defaults to an empty string (resulting in no music) anyway, so there's no harm in it being missing, and the demo's mainhall.tbl doesn't contain these lines, so this change makes it possible to reach the mainhall with demo data.
2017-01-24 12:03:06 -08:00
Fabian Woltermann f376142d57 Merge pull request #1153 from asarium/fix/testCompilation
Fix linking error in unit tests
2017-01-24 14:47:00 +01:00
Cliff Gordon 0cce8fb34c Merge pull request #1054 from asarium/fix/830
Use CMake version in Mac strings file
2017-01-24 07:33:12 -06:00
asarium 5caa85ffa5 Use CMake version in Mac strings file
Fixes #830.
2017-01-23 23:35:14 +01:00
MageKing17 c0c6d4b572 Merge pull request #1152 from asarium/fix/debugWindowFixes
Fix a few minor issues with the new debug window
2017-01-21 13:45:03 -08:00
asarium 7516800c62 Fix default parameter value of gr_flip 2017-01-21 21:56:45 +01:00
asarium cb465d789f Fix linking error in unit tests 2017-01-21 21:48:08 +01:00
asarium 25fa3543f2 Fix a few minor issues with the new debug window
This makes the debug window resizable and also reduces the default size
to ~80% of the used display. This also makes sure that the main window
has input focus after the debug window was created.
2017-01-21 11:48:09 +01:00
niffiwan cb81894632 Merge pull request #1150 from asarium/fix/versionString
Unify version string handling
2017-01-21 10:46:24 +10:00
m!m 18921e720a Merge pull request #1151 from The-E/NoFedoraError
Fixes an assertion due to insufficient amount of hats
2017-01-20 19:03:17 +01:00
m!m 09e18c1164 Merge pull request #1147 from asarium/feature/debugWindow
Reimplement debug window
2017-01-20 18:37:07 +01:00
Fabian Woltermann 637e44d8d2 This would be the correct way to do it 2017-01-20 15:12:23 +01:00
Fabian Woltermann 82ce160093 The logic for joy_down was missing a safety check, which could cause an assertion in Joystick::getHatDownTime if a joystick without a hat (or no joystick at all?) was attached. 2017-01-20 14:31:02 +01:00
asarium 04e5c7e484 Unify version string handling
Currently there are multiple locations in the code where the version is
constructed by printing the individual numbers together. This is mostly
sufficient but it hides information such as the commit hash or the build
name (e.g. RC1). These changes unify that behavior by always using the
version string generated by CMake.
2017-01-20 12:28:47 +01:00
m!m 09586df300 Merge pull request #1037 from asarium/build/macPrebuilts
Use prebuilt libraries for SDL2 framework
2017-01-20 10:47:29 +01:00
m!m 534285324d Merge pull request #1148 from Yarn366/gr_bitmap_offset
Make gr_bitmap obey clip offsets as it did before the OpenGL Core merge
2017-01-19 09:59:28 +01:00
Yarn366 af2514755b Make gr_bitmap obey clip offsets as it did before the OpenGL Core merge 2017-01-18 23:06:43 -05:00
asarium e6dc4d71b6 Add word wrapping 2017-01-18 22:50:14 +01:00
asarium dae0f59911 Add doxygen comments to DebugWindow 2017-01-18 22:17:54 +01:00
asarium c7f523ae46 Add debug window
This allows to show the debug output in a second window in real time.
This system could be expanded further to allow more interactivity but
the current status is good enough.
2017-01-18 18:18:47 +01:00
asarium 5725562435 Improve logic for determining legacy mode
Now it will also check if the old config location exists and if it
doesn't then the new config mode will be used by default. This should
fix #858.
2016-12-20 17:59:41 +01:00
asarium 65d0576a91 Use prebuilt libraries for SDL2 framework 2016-10-13 11:58:10 +02:00
1319 changed files with 144598 additions and 55295 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
+100
View File
@@ -0,0 +1,100 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
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: 4
- Regex: '^(<.*>)$' # standard library includes (won't match deprecated C headers)
Priority: 5
- Regex: '^"[^/]*\.(h)"$' # Local includes
Priority: 1
- Regex: '^".*\.(h)"$' # standard engine includes
Priority: 2
- Regex: '.*' # Catch all in case something is unhandled above
Priority: 3
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
Standard: Cpp11
TabWidth: 4
UseTab: ForIndentation
...
+24
View File
@@ -0,0 +1,24 @@
---
Checks: "-*,\
modernize-*,\
-modernize-raw-string-literal,\
-modernize-use-using,\
-modernize-make-unique,\
performance-*,\
-performance-type-promotion-in-math-fn,\
misc-*,\
-misc-macro-parentheses,\
-misc-misplaced-widening-cast,\
-misc-static-assert,\
-modernize-make-unique,\
"
WarningsAsErrors: ''
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'
...
+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
+3
View File
@@ -2,3 +2,6 @@ root = true
[*.{h,cpp}]
indent_style = tab
[*.sdr]
indent_style = tab
+9 -33
View File
@@ -1,33 +1,3 @@
*.o
*.a
.dirstamp
libtool
ltmain.sh
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
compile
.deps/
code/.deps/
Makefile
Makefile.in
aclocal.m4
autom4te.cache/
config.*
code/fs2_open_*
code/wxFRED2_*
configure
depcomp
install-sh
missing
.svn
*.layout
projects/Xcode/Frameworks/
#========
#OS junk files
[Tt]humbs.db
*.DS_Store
@@ -56,9 +26,6 @@ projects/Xcode/Frameworks/
*.unsuccessfulbuild
ipch/
[Oo]bj/
[Bb]in
[Dd]ebug*/
[Rr]elease*/
Ankh.NoLoad
*.VC.db
*.VC.VC.opendb
@@ -281,3 +248,12 @@ documentation/doxygen/*
.idea/*
projects/*
/.vs
CMakeSettings.json
# Weird files created by Linux
.fuse_hidden*
# This gets ignored by one of the rules above for some reason...
!/code/scripting/lua/LuaConvert.h
!/code/debugconsole/
+3 -3
View File
@@ -1,6 +1,6 @@
[submodule "cmake/external/cotire"]
path = cmake/external/cotire
url = https://github.com/sakra/cotire.git
[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
+171 -102
View File
@@ -1,113 +1,182 @@
language: generic
language: bash
sudo: required
dist: trusty
cache:
directories:
- $HOME/cmake
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
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
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: bintray
user: sirknightly
key:
secure: "CZtvDW/zPf1Nxru21i8Wd+9hgiBRA8VowWBX0gmCOGgRq9WHISttKQQmBWGHuyVZ3rYvtE4Va2bR+2qRN+TFNkUUuOCOQkdBJTCal9nS3G/LprEmsOashG0Q5PTfMMBnlKzKxaxGJW6UhFj2GySmHEAjsFLVpuNWGJeeZgZQ3UE="
file: ci/bintray.json
on:
condition: '"$NIGHTLY_BUILD" == true'
tags: true
apt:
packages: &global_deps
- ninja-build
- libopenal-dev
- libreadline6-dev
- libpng12-dev
- libjpeg62-dev
- liblua5.1-0-dev
- libjansson-dev
- libsdl2-dev
- libfreetype6-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
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="
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="
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: 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
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
packages:
- g++-5
- *global_deps
- os: linux
env: CONFIGURATION="Debug" CC=clang-3.6 CXX=clang++-3.6
addons:
apt:
sources:
- llvm-toolchain-precise
packages:
- clang-3.6
- *global_deps
- 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-trusty'
packages:
- *global_deps
- g++-5
- os: linux
env: CONFIGURATION="Debug" CC=gcc-8 CXX=g++-8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-trusty'
packages:
- g++-8
- *global_deps
- os: linux
env: CONFIGURATION="Debug" CC=clang-4.0 CXX=clang++-4.0 CMAKE_OPTIONS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
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
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-trusty'
packages:
- *global_deps
- g++-5
- os: linux
env: CONFIGURATION="Release" CC=gcc-8 CXX=g++-8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:beineri/opt-qt571-trusty'
packages:
- g++-8
- *global_deps
- os: linux
env: CONFIGURATION="Release" CC=clang-4.0 CXX=clang++-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
- libc++-dev
- 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"
# As long as Windows is still experimental on Travis CI, allow failures
allow_failures:
- 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: windows
env: CONFIGURATION="Release" CMAKE_TOOLSET=v141_xp CMAKE_GENERATOR="Visual Studio 15 2017"
- 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
packages:
- g++-5
- *global_deps
- os: linux
env: CONFIGURATION="Release" CC=clang-3.6 CXX=clang++-3.6
addons:
apt:
sources:
- llvm-toolchain-precise
packages:
- clang-3.6
- *global_deps
- 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/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:
- "./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
before_deploy:
- "./ci/travis/before_deploy.sh"
- if [ "$BUILD_DEPLOYMENT" = true ] ; then ./ci/travis/release.sh ; else ./ci/travis/script.sh ; fi
+21 -20
View File
@@ -40,6 +40,14 @@ set(CMAKE_CONFIGURATION_TYPES Debug Release FastDebug CACHE STRING "Available co
PROJECT(FS2_Open)
find_program(CCACHE_PROGRAM ccache)
# Currently only GCC support ccache properly without generating additional warnings
if(CCACHE_PROGRAM AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message(STATUS "Using ccache for compilation: ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}")
endif()
IF(CMAKE_CROSSCOMPILING)
SET(IMPORT_EXE_DIR "IMPORT_EXE_DIR-NOTFOUND" CACHE FILEPATH "Required for a cross compiling build, point to binary directory of a cmake build for the real OS")
INCLUDE(${IMPORT_EXE_DIR}/ImportExecutables.cmake)
@@ -53,7 +61,7 @@ endif()
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/finder")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/external/rpavlik-cmake-modules")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/external/cotire/CMake")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/external/cotire")
IF(RESET_INSTALL_PREFIX)
IF(NOT $ENV{FS2PATH} STREQUAL "")
@@ -76,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)
@@ -85,7 +92,7 @@ OPTION(FSO_BUILD_TESTS "Build unit tests" OFF)
OPTION(FSO_DEVELOPMENT_MODE "Generate binaries in development mode, only use if you know what you're doing!" OFF)
OPTION(FSO_BUILD_WXFRED2 "Build wxFRED2 binary" OFF)
OPTION(FSO_BUILD_QTFRED "Build qtFRED2 binary" OFF)
IF(WIN32 OR APPLE)
# On windows and mac the default should be to always build the included libraries
@@ -108,13 +115,7 @@ 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)
set(DEFAULT_VAL OFF)
if(MSVC)
# MSVC has been tested
set(DEFAULT_VAL ON)
endif()
OPTION(COTIRE_ENABLE "Enable cotire, this speeds up builds but may cause issues while developing (default = OFF)" ${DEFAULT_VAL})
option(ENABLE_COTIRE "Enable cotire for faster compilation. Enabled by default." ON)
MARK_AS_ADVANCED(FORCE FSO_CMAKE_DEBUG)
MARK_AS_ADVANCED(FORCE FSO_BUILD_INCLUDED_LIBS)
@@ -122,13 +123,11 @@ MARK_AS_ADVANCED(FORCE FSO_USE_OPENALSOFT)
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 COTIRE_ENABLE)
mark_as_advanced(FORCE FSO_INSTALL_DEBUG_FILES)
mark_as_advanced(FORCE ENABLE_COTIRE)
IF(COTIRE_ENABLE)
# Include cotire file from https://github.com/sakra/cotire/
include(cotire)
ENDIF(COTIRE_ENABLE)
# Include cotire file from https://github.com/sakra/cotire/
include(cotire)
INCLUDE(globals)
INCLUDE(toolchain)
@@ -145,6 +144,8 @@ if(FSO_BUILD_APPIMAGE)
include(appimage)
endif()
include(clang-tidy)
# This includes source code for some tools, either used in the build or also for something else
ADD_SUBDIRECTORY(tools)
@@ -158,9 +159,9 @@ IF(FSO_BUILD_FRED2)
ADD_SUBDIRECTORY(fred2)
ENDIF(FSO_BUILD_FRED2)
IF(FSO_BUILD_WXFRED2)
ADD_SUBDIRECTORY(wxfred2)
ENDIF(FSO_BUILD_WXFRED2)
IF(FSO_BUILD_QTFRED)
ADD_SUBDIRECTORY(qtfred)
ENDIF()
if(FSO_BUILD_TESTS)
add_subdirectory(test)
@@ -187,12 +188,12 @@ include(doxygen)
# Print used options to log
IF (WIN32)
message(STATUS "Building FRED2: ${FSO_BUILD_FRED2}")
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 wxFRED: ${FSO_BUILD_WXFRED2}")
message(STATUS "Building qtFRED: ${FSO_BUILD_QTFRED}")
message(STATUS "Fatal warnings: ${FSO_FATAL_WARNINGS}")
+3 -1
View File
@@ -6,6 +6,8 @@ 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>
@@ -37,4 +39,4 @@ You should only use these variables if you know what you're doing
* `MSVC_SIMD_INSTRUCTIONS`: The instruction set the executables will be optimized for.
### Generating an installation package
CMake can automaticall 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.
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.
+39 -13
View File
@@ -1,4 +1,5 @@
version: 1.0.0.{build}
image: Visual Studio 2015
configuration:
- Debug
- Release
@@ -6,16 +7,19 @@ clone_depth: 10
environment:
matrix:
- BuildID: 0
CMAKE_GENERATOR: Visual Studio 12 2013
PlatformToolset: v120_xp
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.9\msvc2015_64
before_build:
- git submodule update --init --recursive
build_script:
- ps: . $Env:APPVEYOR_BUILD_FOLDER/ci/appveyor/build.ps1
test_script:
- ps: . $Env:APPVEYOR_BUILD_FOLDER/ci/appveyor/test.ps1
deploy:
- provider: GitHub
@@ -24,15 +28,37 @@ deploy:
on:
ReleaseBuild: true # deploy on release push only
- provider: BinTray
username: sirknightly
api_key:
secure: pYWqfiZhIWvFYdjVWPXNaHobmnkXIWa4+LwoiyMTEiu4Z0CiCAW0ZrMfTKVkORKz
subject: scp-fs2open
repo: FSO
package: nightly
version: $(VersionName)
publish: true
override: true
- provider: FTP
protocol: sftp
host: scp.indiegames.us
username:
secure: SFivQZfatqWHXK1ijYK3GQ==
password:
secure: q6Zk/412o1ri+NEya1dl1Q==
folder: public_html/builds/nightly/$(VersionName)
on:
NightlyBuild: true # deploy on nightly push only
- provider: FTP
protocol: ftp
host: swc.fs2downloads.com
username:
secure: EXg2ADoKzMduZF90ip2Q0g==
password:
secure: x0LL0uY9yBAQ7JTARhQ6AA==
folder: swc.fs2downloads.com/builds/nightly/$(VersionName)
beta: true
on:
NightlyBuild: true # deploy on nightly push only
- provider: FTP
protocol: ftp
host: swc.fs2downloads.com
username:
secure: EXg2ADoKzMduZF90ip2Q0g==
password:
secure: x0LL0uY9yBAQ7JTARhQ6AA==
folder: swc.fs2downloads.com/builds/test/$(VersionName)
beta: true
on:
TestBuild: true # deploy on test build push only
+44 -6
View File
@@ -4,6 +4,8 @@ class BuildConfig {
[string]$PackageType
[string]$Toolset
[string]$SimdType
[string]$QtDir
[Bool]$SourcePackage
}
$NightlyConfigurations = @(
@@ -12,12 +14,16 @@ $NightlyConfigurations = @(
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9\msvc2015_64";
SourcePackage=$false;
},
[BuildConfig]@{
Generator="Visual Studio 14 2015";
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9\msvc2015";
SourcePackage=$false;
}
)
$ReleaseConfigurations = @(
@@ -26,24 +32,32 @@ $ReleaseConfigurations = @(
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9\msvc2015";
SourcePackage=$true;
}
[BuildConfig]@{
Generator="Visual Studio 14 2015";
PackageType="Win32-AVX";
Toolset="v140_xp";
SimdType="AVX";
QtDir="C:\Qt\5.9\msvc2015";
SourcePackage=$false;
}
[BuildConfig]@{
Generator="Visual Studio 14 2015 Win64";
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.9\msvc2015_64";
SourcePackage=$false;
}
[BuildConfig]@{
Generator="Visual Studio 14 2015 Win64";
PackageType="Win64-AVX";
Toolset="v140_xp";
SimdType="AVX";
QtDir="C:\Qt\5.9\msvc2015_64";
SourcePackage=$false;
}
)
@@ -52,16 +66,21 @@ $BuildConfigurations = $null
# Default values
$ReleaseBuild = $false
$NightlyBuild = $false
$DeployBuild = $false
$TestBuild = $false
if ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^release_(.*)")) {
# Set to true to test either the release or the nightly part of this script
$ReleaseTest = $false
$NightlyTest = $false
$TestBuildTest = $false
if ($ReleaseTest -Or ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^release_(.*)"))) {
# Tag matches
$ReleaseBuild = $true
$PackageName = "fs2_open_$($matches[1])"
$BuildConfigurations = $ReleaseConfigurations
}
if ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^nightly_(.*)")) {
if ($NightlyTest -Or ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REPO_TAG_NAME" -match "^nightly_(.*)"))) {
# Tag matches
$NightlyBuild = $true
$PackageName = "nightly_$($matches[1])"
@@ -69,19 +88,31 @@ if ([System.Convert]::ToBoolean($env:APPVEYOR_REPO_TAG) -And ("$env:APPVEYOR_REP
$BuildConfigurations = $NightlyConfigurations
}
if ($TestBuildTest -Or ([System.Convert]::ToInt32($env:APPVEYOR_PULL_REQUEST_NUMBER) -le 0 -And ("$env:APPVEYOR_REPO_BRANCH" -match "^test\/(.*)"))) {
# Tag matches
$TestBuild = $true
$PackageName = "test_$($matches[1])"
Set-AppveyorBuildVariable 'VersionName' "$($matches[1])"
$BuildConfigurations = $NightlyConfigurations
# Override the revision string so that the builds are named correctly
[System.IO.File]::WriteAllLines("$env:APPVEYOR_BUILD_FOLDER/version_override.cmake", "set(FSO_VERSION_REVISION_STR $env:VersionName)")
}
# Multiply by 2 so that we can add 0 or 1 for debug or release Configs
$buildID = [convert]::ToInt32($env:BuildID) * 2
if ($Env:Configuration -eq "Release") {
$buildID = $buildID + 1
}
Write-Host "$buildID"
if ($ReleaseBuild -Or $NightlyBuild) {
$DeployBuild = $false
if ($ReleaseBuild -Or $NightlyBuild -Or $TestBuild) {
$DeployBuild = $true
}
Set-AppveyorBuildVariable 'ReleaseBuild' "$ReleaseBuild"
Set-AppveyorBuildVariable 'NightlyBuild' "$NightlyBuild"
Set-AppveyorBuildVariable 'TestBuild' "$TestBuild"
New-Item build -type directory
Set-Location -Path build
@@ -94,9 +125,15 @@ if ($DeployBuild) {
}
$buildConfig = $BuildConfigurations[$buildID]
if ($buildConfig.SourcePackage -eq $True) {
7z a -xr'!.git' "$($PackageName)-source-Win.zip" "$env:APPVEYOR_BUILD_FOLDER"
Push-AppveyorArtifact "$($PackageName)-source-Win.zip"
}
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 `
-G "$($buildConfig.Generator)" -T "$($buildConfig.Toolset)" ..
$Configs = @("Release", "FastDebug")
@@ -111,7 +148,8 @@ if ($DeployBuild) {
7z a "$($PackageName)-builds-$($buildConfig.PackageType).zip" "$env:APPVEYOR_BUILD_FOLDER/../install/*"
Push-AppveyorArtifact "$($PackageName)-builds-$($buildConfig.PackageType).zip"
} else {
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS=SSE2 `
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="ON" `
-G "$Env:CMAKE_GENERATOR" -T "$Env:PlatformToolset" ..
cmake --build . --config "$Env:CONFIGURATION" -- /verbosity:minimal
+13
View File
@@ -0,0 +1,13 @@
if ([System.Convert]::ToBoolean($env:ReleaseBuild) -Or [System.Convert]::ToBoolean($env:NightlyBuild) -Or [System.Convert]::ToBoolean($env:TestBuild)) {
# Skip tests for deployment
exit 0
} else {
write "Running unit tests..."
# Run unit tests
&"$pwd\bin\$Env:CONFIGURATION\unittests.exe" --gtest_shuffle 2>&1
if (! ($?)) {
exit 1
}
}
+3
View File
@@ -8,4 +8,7 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
# Nothing to do here
:
elif [ "$TRAVIS_OS_NAME" = "windows" ]; then
# Nothing to do here
:
fi
+31 -7
View File
@@ -1,30 +1,54 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
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
export CXXFLAGS="-m64 -mtune=generic -mfpmath=sse -msse -msse2 -pipe -Wno-unknown-pragmas"
CMAKE="cmake -G Ninja -DFSO_FATAL_WARNINGS=ON"
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"
if [ "$BUILD_DEPLOYMENT" = true ]; then
for config in $BUILD_CONFIGS
do
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
eval $CMAKE -DCMAKE_BUILD_TYPE=$CONFIGURATION -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON ..
eval $CMAKE -DCMAKE_BUILD_TYPE=$CONFIGURATION -DFSO_BUILD_TESTS=ON -DFSO_BUILD_INCLUDED_LIBS=ON -DFSO_BUILD_QTFRED=ON ..
fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
if [ "$BUILD_DEPLOYMENT" = true ]; then
cmake -G "Xcode" -DFSO_FATAL_WARNINGS=ON -DFSO_INSTALL_DEBUG_FILES=ON -DCMAKE_INSTALL_PREFIX="/tmp/release" ..
else
cmake -G "Xcode" ..
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
+26 -2
View File
@@ -2,6 +2,8 @@
RELEASE_BUILD=false
NIGHTLY_BUILD=false
TEST_BUILD=false
BUILD_DEPLOYMENT=false
BUILD_CONFIGS="Release FastDebug"
VERSION_NAME=""
@@ -9,10 +11,12 @@ PACKAGE_NAME=""
RELEASE_PATTERN="^release_(.*)$"
NIGHTLY_PATTERN="^nightly_(.*)$"
TEST_BUILD_PATTERN="^test\/(.*)$"
# These are for testing
NIGHTLY_TEST=false
RELEASE_TEST=false
TEST_BUILD_TEST=false
if [ "$RELEASE_TEST" = true ] || [[ "$TRAVIS_TAG" =~ $RELEASE_PATTERN ]]; then
echo "This is a release tag!";
@@ -25,13 +29,27 @@ if [ "$NIGHTLY_TEST" = true ] || [[ "$TRAVIS_TAG" =~ $NIGHTLY_PATTERN ]]; then
VERSION_NAME="${BASH_REMATCH[1]}";
PACKAGE_NAME="nightly_${BASH_REMATCH[1]}";
fi
if [ "$TEST_BUILD_TEST" = true ] || [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_BRANCH" =~ $TEST_BUILD_PATTERN ]]; then
echo "This is a test build branch!";
TEST_BUILD=true;
if [ "$TEST_BUILD_TEST" = true ]; then
VERSION_NAME="test";
PACKAGE_NAME="test_test";
else
VERSION_NAME="${BASH_REMATCH[1]}";
PACKAGE_NAME="test_${BASH_REMATCH[1]}";
fi
if ([ "$RELEASE_BUILD" = true ] || [ "$NIGHTLY_BUILD" = true ]); then
# Override the revision string so that the builds are named correctly
echo "set(FSO_VERSION_REVISION_STR $VERSION_NAME)" > "$TRAVIS_BUILD_DIR/version_override.cmake"
fi
if ([ "$RELEASE_BUILD" = true ] || [ "$NIGHTLY_BUILD" = true ] || [ "$TEST_BUILD" = true ]); then
BUILD_DEPLOYMENT=true;
fi
if [ "$BUILD_DEPLOYMENT" = true ]; then
if ([ "$TRAVIS_OS_NAME" = "linux" ] && (! [[ "$CC" =~ ^gcc.*$ ]])); then
if ([ "$TRAVIS_OS_NAME" = "linux" ] && (! [[ "$CC" =~ ^gcc-5.*$ ]])); then
echo "Skipping non-release compiler";
exit 0;
fi
@@ -40,10 +58,16 @@ 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
export NIGHTLY_BUILD
export TEST_BUILD
export BUILD_DEPLOYMENT
export BUILD_CONFIGS
export VERSION_NAME
+141
View File
@@ -0,0 +1,141 @@
#!/usr/bin/env python
#
#===- clang-tidy-diff.py - ClangTidy Diff Checker ------------*- python -*--===#
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
#===------------------------------------------------------------------------===#
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 json
import re
import subprocess
import sys
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('-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.')
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 == 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 len(lines_by_file) == 0:
print("No relevant changes found.")
sys.exit(0)
line_filter_json = json.dumps(
[{"name" : name, "lines" : lines_by_file[name]} for name in lines_by_file],
separators = (',', ':'))
quote = "";
if sys.platform == 'win32':
line_filter_json=re.sub(r'"', r'"""', line_filter_json)
else:
quote = "'";
# Run clang-tidy on files containing changes.
command = [args.clang_tidy_binary]
command.append('-line-filter=' + quote + line_filter_json + quote)
if args.fix:
command.append('-fix')
if args.checks != '':
command.append('-checks=' + quote + args.checks + quote)
if args.quiet:
command.append('-quiet')
if args.build_path is not None:
command.append('-p=%s' % args.build_path)
command.extend(lines_by_file.keys())
for arg in args.extra_arg:
command.append('-extra-arg=%s' % arg)
for arg in args.extra_arg_before:
command.append('-extra-arg-before=%s' % arg)
command.extend(clang_tidy_args)
sys.exit(subprocess.call(' '.join(command), shell=True))
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/.*$|test/src/.*$|build/.*$|tools/.*' \
-clang-tidy-binary /usr/bin/clang-tidy-4.0 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
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
set -e
set -u
if [[ ! "$(curl -V)" == *"sftp"* ]]; then
# Before
echo "Before:"
curl -V
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
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 ..
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 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
echo "After:"
curl -V
fi
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
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
fi
done
+12 -9
View File
@@ -4,28 +4,31 @@ set -ex
FILENAME=
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
if [ ! -d "$HOME/cmake/bin" ]; then
if [ ! -d "$HOME/cmake-3.8/bin" ]; then
# If the cache does not currently contain CMake then download and install it
FILENAME=cmake-3.4.3-Linux-x86_64
mkdir -p $HOME/cmake-3.8/
mkdir -p $HOME/cmake/
wget -O /tmp/cmake.tar.gz --no-check-certificate https://www.cmake.org/files/v3.4/$FILENAME.tar.gz
tar -xzf /tmp/cmake.tar.gz -C $HOME/cmake/ --strip-components=1
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/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
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
+14 -3
View File
@@ -5,10 +5,15 @@ set -e
cd build
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
ninja all
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 +22,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
+16 -1
View File
@@ -25,4 +25,19 @@
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
...
}
+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:$PATH
export LD_LIBRARY_PATH="${HERE}"/lib:"$LD_LIBRARY_PATH"
"${HERE}"/bin/$<TARGET_FILE_NAME:Freespace2> $@
+3
View File
@@ -1,6 +1,9 @@
include(WriteCompilerDetectionHeader)
set(CMAKE_CXX_STANDARD_REQUIRED 11)
set(CMAKE_CXX_STANDARD 11)
set(REQUIRED_CXX_FEATURES cxx_rvalue_references cxx_nullptr)
get_property(CMAKE_CXX_KNOWN_FEATURES GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
+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")
+37
View File
@@ -0,0 +1,37 @@
option(ENABLE_CLANG_TIDY "Enable source code checking using clang-tidy" OFF)
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy"
DOC "Path to clang-tidy executable"
)
function(enable_clang_tidy target)
# Not enabled in this configuration
endfunction()
if(NOT ENABLE_CLANG_TIDY)
return()
endif()
if(NOT EXISTS "${CLANG_TIDY_EXE}")
message(SEND_ERROR "clang-tidy: Could not find clang-tidy executable (value of variable is \"${CLANG_TIDY_EXE}\".")
return()
endif()
if(CMAKE_VERSION VERSION_LESS "3.6.0")
message(SEND_ERROR "Clang-tidy support requires CMake 3.6")
return()
endif()
message(STATUS "clang-tidy: Using \"${CLANG_TIDY_EXE}\"")
function(enable_clang_tidy target)
SET(TIDY_OPTIONS "${CLANG_TIDY_EXE}")
if(FSO_FATAL_WARNINGS)
set(TIDY_OPTIONS "${TIDY_OPTIONS};-warnings-as-errors=*")
endif()
set_target_properties(${target} PROPERTIES CXX_CLANG_TIDY "${TIDY_OPTIONS}")
endfunction()
+8 -1
View File
@@ -27,6 +27,7 @@ int main( int argc, char* argv[] )
int SSE = false;
int SSE2 = false;
int AVX = false;
int AVX2 = false;
int info[4];
cpuid(info, 0);
@@ -40,8 +41,14 @@ int main( int argc, char* argv[] )
AVX = (info[2] & ((int)1 << 28)) != 0;
}
if (nIds >= 7){
cpuid(info,0x00000007);
AVX2 = (info[1] & ((int)1 << 5)) != 0;
}
if(AVX)
if (AVX2)
std::cout << "AVX2";
else if(AVX)
std::cout << "AVX";
else if(SSE2)
std::cout << "SSE2";
Submodule cmake/external/cotire deleted from 40a46bf2fb.
+4054
View File
File diff suppressed because it is too large. Load diff
+9
View File
@@ -0,0 +1,9 @@
#ifndef __FREDRC_H
#define __FREDRC_H
#define ABOUT_LINE_1 "FRED2_OPEN - FreeSpace Editor, Version @FSO_PRODUCT_VERSION_STRING@ OpenGL"
#define MAINFRAME_CONTENTS "FRED2_OPEN @FSO_PRODUCT_VERSION_STRING@ - FreeSpace2 Mission Editor\nUntitled\nFRED2\nFreeSpace2 Missions (*.fs2)\n.fs2\nFreeSpace2Mission\nFreeSpace2 Mission"
#endif // __FREDRC_H
+3 -1
View File
@@ -1,5 +1,7 @@
include(platformChecks)
include(Cxx11)
include(platformChecks)
CONFIGURE_FILE(${CMAKE_CURRENT_LIST_DIR}/project.h.in ${GENERATED_SOURCE_DIR}/project.h)
CONFIGURE_FILE(${CMAKE_CURRENT_LIST_DIR}/fred_rc.h.in ${GENERATED_SOURCE_DIR}/fred_rc.h)
+12
View File
@@ -1,5 +1,6 @@
MESSAGE(STATUS "Doing Mac OSX specific things...")
target_compile_definitions(platform INTERFACE APPLE_APP)
SET(EXE_GUI_TYPE MACOSX_BUNDLE)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
@@ -20,3 +21,14 @@ SET(CMAKE_INSTALL_RPATH @loader_path/../Frameworks/)
SET(LIBRAY_DESTINATION "../Frameworks")
set(PLATFORM_MAC TRUE CACHE INTERNAL "" FORCE)
# Generate and don't strip debug symbols
# These settings don't seem to generate debug symbols for code and Freespace2
# so those settings are set manually in code and Freespace2's CMakeLists.txt files
set(CMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS "YES")
set(CMAKE_XCODE_ATTRIBUTE_COPY_PHASE_STRIP "NO")
set(CMAKE_XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT "NO")
set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "NO")
# Generate .dSYM file
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym")
+16
View File
@@ -1,2 +1,18 @@
target_compile_definitions(platform INTERFACE SCP_SOLARIS)
find_library(SOCKET_LIB socket)
if (NOT SOCKET_LIB)
message(FATAL_ERROR "Couldn't find libsocket! Please install it and rerun the configuration.")
else()
target_link_libraries(platform INTERFACE "${SOCKET_LIB}")
endif()
find_library(NSL_LIB nsl)
if (NOT NSL_LIB)
message(FATAL_ERROR "Couldn't find libnsl! Please install it and rerun the configuration.")
else()
target_link_libraries(platform INTERFACE "${NSL_LIB}")
endif()
+16
View File
@@ -7,6 +7,7 @@ include(CheckLibraryExists)
include(CheckPrototypeDefinition)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CheckCXXSymbolExists)
include(CheckTypeSize)
CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
@@ -14,10 +15,22 @@ CHECK_INCLUDE_FILE_CXX("cxxabi.h" HAVE_CXXAPI_H)
CHECK_TYPE_SIZE("max_align_t" MAX_ALIGN_T)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_REQUIRED_FLAGS "-std=c++11") # required for g++ <= 5
endif()
set(CMAKE_EXTRA_INCLUDE_FILES "cstddef")
CHECK_TYPE_SIZE("std::max_align_t" STD_MAX_ALIGN_T LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES "type_traits")
CHECK_TYPE_SIZE("std::is_trivially_copyable<int>" STD_IS_TRIVIALLY_COPYABLE LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES)
CHECK_TYPE_SIZE("char32_t" CHAR32_T LANGUAGE CXX)
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)
@@ -28,5 +41,8 @@ CHECK_FUNCTION_EXISTS(strlwr HAVE_STRLWR)
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
check_symbol_exists(_snprintf "stdio.h" HAVE__SNPRINTF)
set(PLATFORM_CHECK_HEADER "${GENERATED_SOURCE_DIR}/platformChecks.h")
CONFIGURE_FILE(${CMAKE_CURRENT_LIST_DIR}/platformChecks.h.in "${PLATFORM_CHECK_HEADER}")
+9
View File
@@ -8,6 +8,9 @@
#cmakedefine HAVE_MAX_ALIGN_T
#cmakedefine HAVE_STD_MAX_ALIGN_T
#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE
#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE_ARRAY
#cmakedefine01 IS_64BIT
#cmakedefine01 HAVE_STRCASECMP
@@ -19,4 +22,10 @@
#cmakedefine01 HAVE_STRINGS_H
#cmakedefine01 HAVE_CHAR32_T
#cmakedefine01 HAVE_UNICODE_CHAR_LITERAL
#cmakedefine01 HAVE_SNPRINTF
#cmakedefine01 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")
+22 -11
View File
@@ -7,14 +7,20 @@ 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)
unset(COMPILER_FLAGS)
# These are the default values
set(C_BASE_FLAGS "-march=native -pipe")
set(CXX_BASE_FLAGS "-march=native -pipe")
# For C and C++, the values can be overwritten independently
if(DEFINED ENV{CXXFLAGS})
set(COMPILER_FLAGS $ENV{CXXFLAGS})
set(CXX_BASE_FLAGS $ENV{CXXFLAGS})
endif()
if(DEFINED ENV{CFLAGS})
set(C_BASE_FLAGS $ENV{CFLAGS})
endif()
if(NOT COMPILER_FLAGS)
set(COMPILER_FLAGS "-march=native -pipe")
endif()
# Initialize with an empty string to make sure we always get a clean start
set(COMPILER_FLAGS "")
# This is a slight hack since our flag setup is a bit more complicated
_enable_extra_compiler_warnings_flags()
@@ -58,23 +64,25 @@ endif()
set(COMPILER_FLAGS "${COMPILER_FLAGS} ${SANITIZE_FLAGS}")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-function")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wformat-security")
# 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")
set(CMAKE_CXX_FLAGS ${COMPILER_FLAGS})
set(CMAKE_C_FLAGS ${COMPILER_FLAGS})
# Always use the base flags and add our compiler flags at the bacl
set(CMAKE_CXX_FLAGS "${CXX_BASE_FLAGS} ${COMPILER_FLAGS}")
set(CMAKE_C_FLAGS "${C_BASE_FLAGS} ${COMPILER_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
set(CMAKE_C_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
@@ -96,3 +104,6 @@ if (FSO_FATAL_WARNINGS)
# Make warnings fatal if the right variable is set
target_compile_options(compiler INTERFACE "-Werror")
endif()
# Always define this to make sure that the fixed width format macros are available
target_compile_definitions(compiler INTERFACE __STDC_FORMAT_MACROS)
+33 -10
View File
@@ -9,14 +9,20 @@ option(GCC_ENABLE_LEAK_CHECK "Enable -fsanitize=leak" OFF)
option(GCC_ENABLE_ADDRESS_SANITIZER "Enable -fsanitize=address" OFF)
option(GCC_ENABLE_SANITIZE_UNDEFINED "Enable -fsanitize=undefined" OFF)
unset(COMPILER_FLAGS)
# These are the default values
set(C_BASE_FLAGS "-march=native -pipe")
set(CXX_BASE_FLAGS "-march=native -pipe")
# For C and C++, the values can be overwritten independently
if(DEFINED ENV{CFLAGS})
set(C_BASE_FLAGS $ENV{CFLAGS})
endif()
if(DEFINED ENV{CXXFLAGS})
set(COMPILER_FLAGS $ENV{CXXFLAGS})
set(CXX_BASE_FLAGS $ENV{CXXFLAGS})
endif()
if(NOT COMPILER_FLAGS)
set(COMPILER_FLAGS "-march=native -pipe")
endif()
# Initialize with an empty string to make sure we always get a clean start
set(COMPILER_FLAGS "")
# This is a slight hack since our flag setup is a bit more complicated
_enable_extra_compiler_warnings_flags()
@@ -70,18 +76,31 @@ endif()
set(COMPILER_FLAGS "${COMPILER_FLAGS} ${SANITIZE_FLAGS}")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-function")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wformat-security")
# 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")
set(CMAKE_CXX_FLAGS ${COMPILER_FLAGS})
set(CMAKE_C_FLAGS ${COMPILER_FLAGS})
# Always use the base flags and add our compiler flags at the bacl
set(CMAKE_CXX_FLAGS "${CXX_BASE_FLAGS} ${COMPILER_FLAGS}")
set(CMAKE_C_FLAGS "${C_BASE_FLAGS} ${COMPILER_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
set(CMAKE_C_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
@@ -93,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)
@@ -117,3 +137,6 @@ if (FSO_FATAL_WARNINGS)
# Make warnings fatal if the right variable is set
target_compile_options(compiler INTERFACE "-Werror")
endif()
# Always define this to make sure that the fixed width format macros are available
target_compile_definitions(compiler INTERFACE __STDC_FORMAT_MACROS=1)
+9 -6
View File
@@ -33,14 +33,17 @@ set(WARNING_FLAGS
/wd4311 # Disables warnings about casting pointer types to ints. The funny thing is these warnings can't be resolved, just disabled... - m!m
/wd4302 # Same as above - m!m
/wd4366 # The result of the unary '&' operator may be unaligned - m!m
/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
)
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")
set(CMAKE_CXX_FLAGS "/MP /GS- /analyze- /Zc:wchar_t /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo")
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_EXE_LINKER_FLAGS "/MANIFEST /DYNAMICBASE:NO /SAFESEH:NO /ERRORREPORT:PROMPT /NOLOGO")
set(CMAKE_STATIC_LINKER_FLAGS "")
@@ -88,7 +91,7 @@ ENDIF(MSVC_USE_RUNTIME_DLL)
INCLUDE(MSVCMultipleProcessCompile)
# Visual Studio supports compiling for multiple vector instruction sets
SET(POSSIBLE_INSTUCTION_SETS "" SSE SSE2 AVX)
SET(POSSIBLE_INSTUCTION_SETS "" SSE SSE2 AVX AVX2)
if (NOT DEFINED MSVC_SIMD_INSTRUCTIONS)
detect_simd_instructions(MSVC_DETECTED_SIMD_INSTRUCTIONS)
@@ -133,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")
+2 -2
View File
@@ -20,7 +20,7 @@ ENDIF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# Copy release settings to FastDebug
set(CMAKE_C_FLAGS_FASTDEBUG "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_FASTDEBUG "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS_FASTDEBUG "${CMAKE_EXE_LINKER_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS_FASTDEBUG "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_STATIC_LINKER_FLAGS_FASTDEBUG "${CMAKE_STATIC_LINKER_FLAGS_RELEASE}")
if (MSVC)
@@ -30,4 +30,4 @@ if (MSVC)
string(REPLACE "/MD" "/MDd" CMAKE_CXX_FLAGS_FASTDEBUG "${CMAKE_CXX_FLAGS_FASTDEBUG}")
string(REPLACE "/MT" "/MTd" CMAKE_CXX_FLAGS_FASTDEBUG "${CMAKE_CXX_FLAGS_FASTDEBUG}")
endif()
endif()
+70 -23
View File
@@ -10,7 +10,7 @@ FUNCTION(ADD_IMPORTED_LIB NAME INCLUDES LIBS)
target_link_libraries(${NAME} INTERFACE "${LIBS}")
target_include_directories(${NAME} INTERFACE "${INCLUDES}")
target_include_directories(${NAME} SYSTEM INTERFACE "${INCLUDES}")
ENDFUNCTION(ADD_IMPORTED_LIB)
MACRO(PKG_CONFIG_LIB_RESOLVE NAME OUTVAR)
@@ -66,6 +66,22 @@ ENDIF(EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${FILE}\")
SET(${OUTVAR} "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${NAME} PARENT_SCOPE)
ENDFUNCTION(EP_CHECK_FILE_EXISTS)
MACRO(COPY_FILE_TO_TARGET _target _file)
if(UNIX)
ADD_CUSTOM_COMMAND(
TARGET ${_target} POST_BUILD
COMMAND cp -a "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
COMMENT "copying '${_file}'..."
)
else()
ADD_CUSTOM_COMMAND(
TARGET ${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
COMMENT "copying '${_file}'..."
)
endif()
endmacro(COPY_FILE_TO_TARGET)
MACRO(COPY_FILES_TO_TARGET _target)
if(UNIX)
ADD_CUSTOM_COMMAND(
@@ -76,19 +92,7 @@ MACRO(COPY_FILES_TO_TARGET _target)
endif()
FOREACH(file IN LISTS TARGET_COPY_FILES)
if(UNIX)
ADD_CUSTOM_COMMAND(
TARGET ${_target} POST_BUILD
COMMAND cp -a "${file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
COMMENT "copying '${file}'..."
)
else()
ADD_CUSTOM_COMMAND(
TARGET ${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
COMMENT "copying '${file}'..."
)
endif()
COPY_FILE_TO_TARGET("${_target}" "${file}")
ENDFOREACH(file)
ENDMACRO(COPY_FILES_TO_TARGET)
@@ -137,23 +141,28 @@ macro(set_if_not_defined VAR VALUE)
endmacro(set_if_not_defined)
macro(configure_cotire target)
IF(COTIRE_ENABLE)
if(ENABLE_COTIRE)
# Disable unity build as it doesn't work well for us
set_target_properties(${target} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
# add ignored paths for the precompiled header here
set_target_properties(code PROPERTIES COTIRE_PREFIX_HEADER_IGNORE_PATH
"${CMAKE_SOURCE_DIR};${CMAKE_BINARY_DIR};${FFMPEG_ROOT_DIR}")
cotire(${target})
ENDIF(COTIRE_ENABLE)
endif()
endmacro(configure_cotire)
macro(add_target_copy_files)
INSTALL(FILES ${ARGN}
DESTINATION ${LIBRAY_DESTINATION}
)
foreach(file ${ARGN})
if (IS_DIRECTORY "${file}")
INSTALL(DIRECTORY ${file}
DESTINATION ${LIBRAY_DESTINATION}
)
else()
INSTALL(FILES ${file}
DESTINATION ${LIBRAY_DESTINATION}
)
endif()
SET(TARGET_COPY_FILES ${TARGET_COPY_FILES} ${ARGN} CACHE INTERNAL "" FORCE)
SET(TARGET_COPY_FILES ${TARGET_COPY_FILES} ${file} CACHE INTERNAL "" FORCE)
endforeach()
endmacro(add_target_copy_files)
function(detect_simd_instructions _out_var)
@@ -188,3 +197,41 @@ function(suppress_warnings _target)
target_compile_options(${_target} PRIVATE "-w")
endif()
endfunction(suppress_warnings)
function(list_target_dependencies _target _out_var)
set(out_list)
set(work_libs ${_target})
list(LENGTH work_libs libs_length)
while(libs_length GREATER 0)
list(GET work_libs 0 current)
list(REMOVE_AT work_libs 0)
list(APPEND out_list ${current})
get_target_property(current_libs ${current} INTERFACE_LINK_LIBRARIES)
if(current_libs)
foreach(lib ${current_libs})
if (TARGET ${lib})
list(APPEND work_libs ${lib})
endif (TARGET ${lib})
endforeach(lib)
endif(current_libs)
list(LENGTH work_libs libs_length)
endwhile(libs_length GREATER 0)
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)
+2 -2
View File
@@ -7,8 +7,8 @@ if (EXISTS "${PROJECT_SOURCE_DIR}/version_override.cmake")
endif()
set_if_not_defined(FSO_VERSION_MAJOR 3)
set_if_not_defined(FSO_VERSION_MINOR 7)
set_if_not_defined(FSO_VERSION_BUILD 5)
set_if_not_defined(FSO_VERSION_MINOR 8)
set_if_not_defined(FSO_VERSION_BUILD 1)
# A numeric revision e.g. the CI build number
set_if_not_defined(FSO_VERSION_REVISION 0)
+32 -4
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})
@@ -21,20 +21,28 @@ TARGET_INCLUDE_DIRECTORIES(code PUBLIC ${GENERATED_SOURCE_DIR}/code)
target_link_libraries(code PUBLIC OpenGL)
TARGET_LINK_LIBRARIES(code PUBLIC ${OPENAL_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC openal)
TARGET_LINK_LIBRARIES(code PUBLIC ${LUA_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC ${PNG_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC ${JPEG_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC ${SDL_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC sdl2)
TARGET_LINK_LIBRARIES(code PUBLIC ffmpeg)
TARGET_LINK_LIBRARIES(code PUBLIC utfcpp)
TARGET_LINK_LIBRARIES(code PUBLIC platform)
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)
enable_clang_tidy(code)
IF (FSO_USE_SPEECH)
find_package(Speech REQUIRED)
target_link_libraries(code PUBLIC speech)
@@ -53,7 +61,27 @@ IF(FSO_BUILD_TOOLS)
ADD_SUBDIRECTORY(cfileextractor)
ENDIF(FSO_BUILD_TOOLS)
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()
include(util)
configure_cotire(code)
include(../cmake/Cxx11.cmake)
# Ensure that Xcode generates debug symbols on macOS for Debug builds
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS[variant=Debug] "YES")
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_COPY_PHASE_STRIP[variant=Debug] "NO")
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT[variant=Debug] "NO")
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN[variant=Debug] "NO")
+4 -9
View File
@@ -567,9 +567,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 +587,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 +619,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 +643,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
+3
View File
@@ -87,6 +87,7 @@ namespace AI {
Fix_heat_seeker_stealth_bug,
Fix_linked_primary_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 +110,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,
+8 -1
View File
@@ -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);
@@ -433,6 +435,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 +462,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:")) {
@@ -498,7 +504,8 @@ void parse_ai_profiles_tbl(const char *filename)
}
// find next valid option
skip_to_start_of_string_either("$", "#");
if (!skip_to_start_of_string_either("$", "#"))
break;
saved_Mp = Mp;
}
}
+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);
+119 -196
View File
@@ -58,6 +58,8 @@
#include "physics/physics.h"
#include "playerman/player.h"
#include "render/3d.h"
#include "scripting/api/objs/wing.h"
#include "scripting/scripting.h"
#include "ship/afterburner.h"
#include "ship/awacs.h"
#include "ship/ship.h"
@@ -68,7 +70,7 @@
#include "weapon/swarm.h"
#include "weapon/weapon.h"
#include <map>
#include <limits.h>
#include <climits>
#ifdef _MSC_VER
@@ -745,6 +747,8 @@ void parse_ai_class()
set_aic_flag(aicp, "$smart afterburner management:", AI::Profile_Flags::Smart_afterburner_management);
set_aic_flag(aicp, "$free afterburner use:", AI::Profile_Flags::Free_afterburner_use);
set_aic_flag(aicp, "$allow rapid secondary dumbfire:", AI::Profile_Flags::Allow_rapid_secondary_dumbfire);
set_aic_flag(aicp, "$huge turret weapons ignore bombs:", AI::Profile_Flags::Huge_turret_weapons_ignore_bombs);
@@ -764,6 +768,8 @@ void parse_ai_class()
set_aic_flag(aicp, "$all ships manage shields:", AI::Profile_Flags::All_ships_manage_shields);
set_aic_flag(aicp, "$ai can slow down when attacking big ships:", AI::Profile_Flags::Ai_can_slow_down_attacking_big_ships);
set_aic_flag(aicp, "$use actual primary range:", AI::Profile_Flags::Use_actual_primary_range);
}
void reset_ai_class_names()
@@ -1132,7 +1138,7 @@ void ai_update_danger_weapon(int attacked_objnum, int weapon_objnum)
// If rvec != NULL, use it to match bank by calling vm_matrix_interpolate.
// (rvec defaults to NULL)
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, int sexp_flags)
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, int sexp_flags)
{
matrix curr_orient;
vec3d vel_in, vel_out, desired_fvec, src;
@@ -1213,10 +1219,9 @@ void ai_turn_towards_vector(vec3d *dest, object *objp, float frametime, float tu
}
// Dave Andsager: The non-indented lines here are debug code to help you track down the problem in the physics
// that is causing ships to inexplicably rotate very far. If you hit the Int3(), set the next statement to be
// that is causing ships to inexplicably rotate very far. If you see the message below in the log, set the next statement to be
// the one marked "HERE". (Do this clicking the cursor there, then right clicking. Choose the right option.)
// This will allow you to rerun vm_forward_interpolate() with the values that caused the error.
// Note, you'll need to enable the Int3() about ten lines below.
#ifndef NDEBUG
vec3d tvec = objp->orient.vec.fvec;
vec3d vel_in_copy;
@@ -1238,13 +1243,13 @@ objp->orient = objp_orient_copy; //-V587
} else {
vm_forward_interpolate(&desired_fvec, &curr_orient, &vel_in, delta_time, delta_bank, &objp->orient, &vel_out, &vel_limit, &acc_limit);
}
#ifndef NDEBUG
if (!((objp->type == OBJ_WEAPON) && (Weapon_info[Weapons[objp->instance].weapon_info_index].subtype == WP_MISSILE))) {
Assertion(!(delta_time < 0.25f && vm_vec_dot(&objp->orient.vec.fvec, &tvec) < 0.1f), "A ship rotated too far. Offending vessel is %s, please investigate.\n", Ships[objp->instance].ship_name);
}
#endif
#ifndef NDEBUG
if (!((objp->type == OBJ_WEAPON) && (Weapon_info[Weapons[objp->instance].weapon_info_index].subtype == WP_MISSILE))) {
if (delta_time < 0.25f && vm_vec_dot(&objp->orient.vec.fvec, &tvec) < 0.1f)
mprintf(("A ship rotated too far. Offending vessel is %s, please investigate.\n", Ships[objp->instance].ship_name));
}
#endif
pip->rotvel = vel_out;
}
@@ -1342,6 +1347,7 @@ void ai_object_init(object * obj, int ai_index)
aip->wing = -1; // Member of what wing? -1 means none.
aip->ai_class = Ship_info[Ships[obj->instance].ship_info_index].ai_class;
aip->behavior = AIM_NONE;
aip->mode = aip->behavior;
}
/**
@@ -1501,12 +1507,12 @@ void turn_towards_point(object *objp, vec3d *point, vec3d *slide_vec, float bank
if (aip->ai_flags[AI::AI_Flags::Formation_object, AI::AI_Flags::Formation_wing]) {
if (&Objects[aip->goal_objnum] != objp) {
float rotvel_z = objp->phys_info.rotvel.xyz.z;
ai_turn_towards_vector(point, objp, flFrametime, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, slide_vec, NULL, bank_override, 0);
ai_turn_towards_vector(point, objp, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, slide_vec, nullptr, bank_override, 0);
objp->phys_info.rotvel.xyz.z = rotvel_z;
}
} else {
// normal turn
ai_turn_towards_vector(point, objp, flFrametime, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, slide_vec, NULL, bank_override, 0);
ai_turn_towards_vector(point, objp, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, slide_vec, nullptr, bank_override, 0);
}
}
@@ -1521,7 +1527,7 @@ void turn_away_from_point(object *objp, vec3d *point, float bank_override)
vm_vec_sub(&opposite_point, &objp->pos, point);
vm_vec_add2(&opposite_point, &objp->pos);
ai_turn_towards_vector(&opposite_point, objp, flFrametime, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, NULL, NULL, bank_override, AITTV_FAST);
ai_turn_towards_vector(&opposite_point, objp, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, nullptr, nullptr, bank_override, AITTV_FAST);
}
@@ -1790,7 +1796,7 @@ float get_wing_lowest_av_ab_speed(object *objp)
wingnum = aip->wing;
if (((shipp->flags[Ship::Ship_Flags::Afterburner_locked]) || !(sip->flags[Ship::Info_Flags::Afterburner])) || (shipp->current_max_speed < 5.0f) || (objp->phys_info.afterburner_max_vel.xyz.z <= shipp->current_max_speed) || !(aip->ai_flags[AI::AI_Flags::Free_afterburner_use])) {
if (((shipp->flags[Ship::Ship_Flags::Afterburner_locked]) || !(sip->flags[Ship::Info_Flags::Afterburner])) || (shipp->current_max_speed < 5.0f) || (objp->phys_info.afterburner_max_vel.xyz.z <= shipp->current_max_speed) || !(aip->ai_flags[AI::AI_Flags::Free_afterburner_use] || aip->ai_profile_flags[AI::Profile_Flags::Free_afterburner_use])) {
lowest_max_av_ab_speed = shipp->current_max_speed;
}
else
@@ -1815,7 +1821,7 @@ float get_wing_lowest_av_ab_speed(object *objp)
if ((oaip->mode == AIM_WAYPOINTS) && (oaip->wing == wingnum) && (oaip->ai_flags[AI::AI_Flags::Formation_object, AI::AI_Flags::Formation_wing])) {
float cur_max;
if ((oshipp->flags[Ship::Ship_Flags::Afterburner_locked]) || !(osip->flags[Ship::Info_Flags::Afterburner]) || (o->phys_info.afterburner_max_vel.xyz.z <= oshipp->current_max_speed) || !(oaip->ai_flags[AI::AI_Flags::Free_afterburner_use])) {
if ((oshipp->flags[Ship::Ship_Flags::Afterburner_locked]) || !(osip->flags[Ship::Info_Flags::Afterburner]) || (o->phys_info.afterburner_max_vel.xyz.z <= oshipp->current_max_speed) || !(oaip->ai_flags[AI::AI_Flags::Free_afterburner_use] || oaip->ai_profile_flags[AI::Profile_Flags::Free_afterburner_use])) {
cur_max = oshipp->current_max_speed;
}
else
@@ -3449,35 +3455,6 @@ float compute_time_to_enemy(float dist_to_enemy, object *pobjp)
return time_to_enemy + flFrametime;
}
// Stuff *dot and *tts.
// *dot is always computed. If dot is less than zero, the magnitude is
// incorrect, not having been divided by distance.
// If *dot is > 0.0f, then tts is computed. This is the time it will take object
// *objp to get to *pos, assuming it moves right at it.
void fds_aux(float *dot, float *tts, vec3d *pos, float dtime, object *objp)
{
vec3d v2s;
vm_vec_sub(&v2s, pos, &objp->pos);
*dot = vm_vec_dot(&v2s, &objp->orient.vec.fvec);
if (*dot > 0.0f) {
float dist;
dist = vm_vec_dist(&objp->pos, pos);
if (dist > 0.1f)
*dot /= dist;
else
*dot = 1.0f;
if (objp->phys_info.speed > 0.1f)
*tts = dist / objp->phys_info.speed;
else
*tts = dist * 100.0f;
}
}
// --------------------------------------------------------------------------
void ai_set_positions(object *pl_objp, object *en_objp, ai_info *aip, vec3d *player_pos, vec3d *enemy_pos)
{
@@ -3815,7 +3792,7 @@ float ai_path_0()
int path_num;
Assert(aip->active_goal >= 0);
ai_goal *aigp = &aip->goals[aip->active_goal];
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] || aigp->flags[AI::Goal_Flags::Docker_index_valid]);
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] && aigp->flags[AI::Goal_Flags::Docker_index_valid]);
path_num = ai_return_path_num_from_dockbay(&Objects[aip->goal_objnum], aigp->dockee.index);
ai_find_path(Pl_objp, aip->goal_objnum, path_num, 0);
@@ -3893,7 +3870,7 @@ float ai_path_0()
}
if (dist_to_goal > 0.1f)
ai_turn_towards_vector(&gcvp, Pl_objp, flFrametime, sip->srotation_time, slop_vec, NULL, 0.0f, 0);
ai_turn_towards_vector(&gcvp, Pl_objp, sip->srotation_time, slop_vec, nullptr, 0.0f, 0);
// Code to control speed is MUCH less forgiving in path following than in waypoint
// following. Must be very close to path or might hit objects.
@@ -3958,7 +3935,7 @@ float ai_path_1()
int path_num;
Assert(aip->active_goal >= 0);
ai_goal *aigp = &aip->goals[aip->active_goal];
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] || aigp->flags[AI::Goal_Flags::Docker_index_valid]);
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] && aigp->flags[AI::Goal_Flags::Docker_index_valid]);
path_num = ai_return_path_num_from_dockbay(&Objects[aip->goal_objnum], aigp->dockee.index);
ai_find_path(Pl_objp, aip->goal_objnum, path_num, 0);
@@ -4035,10 +4012,10 @@ float ai_path_1()
if (r <= 1.0f) {
vec3d midpoint;
vm_vec_avg3(&midpoint, &gcvp, &closest_point, &closest_point);
ai_turn_towards_vector(&midpoint, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0, prvec);
ai_turn_towards_vector(&midpoint, Pl_objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0, prvec);
}
else {
ai_turn_towards_vector(&gcvp, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0, prvec);
ai_turn_towards_vector(&gcvp, Pl_objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0, prvec);
}
}
@@ -4383,11 +4360,11 @@ void ai_fly_to_target_position(vec3d* target_pos, bool* pl_done_p=NULL, bool* pl
vm_vector_2_matrix(&Pl_objp->orient, &perp, NULL, NULL);
} else {
vm_vec_scale_add(&perp, &Pl_objp->pos, &Autopilot_flight_leader->phys_info.vel, 1000.0f);
ai_turn_towards_vector(&perp, Pl_objp, flFrametime, sip->srotation_time*3.0f*scale, slop_vec, NULL, 0.0f, 0);
ai_turn_towards_vector(&perp, Pl_objp, sip->srotation_time*3.0f*scale, slop_vec, nullptr, 0.0f, 0);
}
} else {
if (dist_to_goal > 0.1f) {
ai_turn_towards_vector(target_pos, Pl_objp, flFrametime, sip->srotation_time*3.0f*scale, slop_vec, NULL, 0.0f, 0);
ai_turn_towards_vector(target_pos, Pl_objp, sip->srotation_time*3.0f*scale, slop_vec, nullptr, 0.0f, 0);
}
}
@@ -4441,7 +4418,7 @@ void ai_fly_to_target_position(vec3d* target_pos, bool* pl_done_p=NULL, bool* pl
ab_allowed = false;
}
if (!(sip->flags[Ship::Info_Flags::Afterburner]) || (shipp->flags[Ship::Ship_Flags::Afterburner_locked]) || !(aip->ai_flags[AI::AI_Flags::Free_afterburner_use])) {
if (!(sip->flags[Ship::Info_Flags::Afterburner]) || (shipp->flags[Ship::Ship_Flags::Afterburner_locked]) || !(aip->ai_flags[AI::AI_Flags::Free_afterburner_use] || aip->ai_profile_flags[AI::Profile_Flags::Free_afterburner_use])) {
ab_allowed = false;
}
@@ -4612,6 +4589,11 @@ void ai_waypoints()
ai_mission_wing_goal_complete( Ships[Pl_objp->instance].wingnum, &(aip->goals[aip->active_goal]) );
mission_log_add_entry( LOG_WAYPOINTS_DONE, Wings[Ships[Pl_objp->instance].wingnum].name, aip->wp_list->get_name(), -1 );
}
// adds scripting hook for 'On Waypoints Done' --wookieejedi
Script_system.SetHookObject("Ship", &Objects[Ships[Pl_objp->instance].objnum]);
Script_system.SetHookVar("Wing", 'o', scripting::api::l_Wing.Set(Ships[Pl_objp->instance].wingnum));
Script_system.RunCondition(CHA_ONWAYPOINTSDONE);
Script_system.RemHookVars(2, "Ship", "Wing");
}
}
}
@@ -5052,7 +5034,7 @@ void slide_face_ship()
dist = vm_vec_normalized_dir(&vec_from_enemy, &Pl_objp->pos, &En_objp->pos);
ai_turn_towards_vector(&En_objp->pos, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&En_objp->pos, Pl_objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0);
dot_from_enemy = vm_vec_dot(&vec_from_enemy, &En_objp->orient.vec.fvec);
@@ -5235,7 +5217,7 @@ vec3d G_predicted_pos, G_fire_pos;
// Else
// Select Any ol' weapon.
// Returns primary_bank index.
int ai_select_primary_weapon_OLD(object *objp, object *other_objp, Weapon::Info_Flags flags)
static int ai_select_primary_weapon_OLD(const object *objp, Weapon::Info_Flags flags)
{
ship *shipp = &Ships[objp->instance];
ship_weapon *swp = &shipp->weapons;
@@ -5326,7 +5308,7 @@ int ai_select_primary_weapon(object *objp, object *other_objp, Weapon::Info_Flag
//not using the new AI, use the old version of this function instead.
if (!(Ai_info[shipp->ai_index].ai_profile_flags[AI::Profile_Flags::Smart_primary_weapon_selection]))
{
return ai_select_primary_weapon_OLD(objp, other_objp, flags);
return ai_select_primary_weapon_OLD(objp, flags);
}
Assert( shipp->ship_info_index >= 0 && shipp->ship_info_index < static_cast<int>(Ship_info.size()));
@@ -5372,7 +5354,7 @@ int ai_select_primary_weapon(object *objp, object *other_objp, Weapon::Info_Flag
if (Weapon_info[swp->primary_bank_weapons[i]].wi_flags[Weapon::Info_Flags::Capital_plus])
{
swp->current_primary_bank = i;
nprintf(("AI", "%i: Ship %s selecting weapon %s\n", Framecount, Ships[objp->instance].ship_name, Weapon_info[swp->primary_bank_weapons[i]].name));
nprintf(("AI", "%i: Ship %s selecting weapon %s (capital+) vs target %s\n", Framecount, Ships[objp->instance].ship_name, Weapon_info[swp->primary_bank_weapons[i]].name, Ships[other_objp->instance].ship_name));
return i;
}
}
@@ -5410,6 +5392,7 @@ int ai_select_primary_weapon(object *objp, object *other_objp, Weapon::Info_Flag
i_hullfactor_prev_bank = 0; // Just switch to the first one
}
swp->current_primary_bank = i_hullfactor_prev_bank; // Select the best weapon
nprintf(("AI", "%i: Ship %s selecting weapon %s (no shields) vs target %s\n", Framecount, Ships[objp->instance].ship_name, Weapon_info[swp->primary_bank_weapons[i_hullfactor_prev_bank]].name, (other_objp->type == OBJ_SHIP ? Ships[other_objp->instance].ship_name : "non-ship") ));
return i_hullfactor_prev_bank; // Return
}
@@ -5424,6 +5407,7 @@ int ai_select_primary_weapon(object *objp, object *other_objp, Weapon::Info_Flag
if ((Weapon_info[swp->primary_bank_weapons[bank_index]].wi_flags[Weapon::Info_Flags::Pierce_shields]) && !(Weapon_info[swp->primary_bank_weapons[bank_index]].wi_flags[Weapon::Info_Flags::Capital_plus]))
{
nprintf(("AI", "%i: Ship %s selecting weapon %s (>10%% shields)\n", Framecount, Ships[objp->instance].ship_name, Weapon_info[swp->primary_bank_weapons[bank_index]].name));
return swp->current_primary_bank;
}
}
@@ -5438,6 +5422,7 @@ int ai_select_primary_weapon(object *objp, object *other_objp, Weapon::Info_Flag
if ((Weapon_info[weapon_info_index].wi_flags[Weapon::Info_Flags::Pierce_shields]) && !(Weapon_info[swp->primary_bank_weapons[i]].wi_flags[Weapon::Info_Flags::Capital_plus]))
{
swp->current_primary_bank = i;
nprintf(("AI", "%i: Ship %s selecting weapon %s (>10%% shields)\n", Framecount, Ships[objp->instance].ship_name, Weapon_info[swp->primary_bank_weapons[i]].name));
return i;
}
}
@@ -5472,6 +5457,7 @@ int ai_select_primary_weapon(object *objp, object *other_objp, Weapon::Info_Flag
i_hullfactor_prev_bank = 0; // Just switch to the first one
}
swp->current_primary_bank = i_hullfactor_prev_bank; // Select the best weapon
nprintf(("AI", "%i: Ship %s selecting weapon %s (<50%% shields)\n", Framecount, Ships[objp->instance].ship_name, Weapon_info[swp->primary_bank_weapons[i_hullfactor_prev_bank]].name));
return i_hullfactor_prev_bank; // Return
}
else
@@ -5501,6 +5487,7 @@ int ai_select_primary_weapon(object *objp, object *other_objp, Weapon::Info_Flag
i_hullfactor_prev_bank = 0; // Just switch to the first one
}
swp->current_primary_bank = i_hullfactor_prev_bank; // Select the best weapon
nprintf(("AI", "%i: Ship %s selecting weapon %s (>50%% shields)\n", Framecount, Ships[objp->instance].ship_name, Weapon_info[swp->primary_bank_weapons[i_hullfactor_prev_bank]].name));
return i_hullfactor_prev_bank; // Return
}
}
@@ -5528,7 +5515,9 @@ void set_primary_weapon_linkage(object *objp)
// If trying to destroy a big ship (i.e., not disable/disarm), always unleash all weapons
if ( Ship_info[Ships[Objects[aip->target_objnum].instance].ship_info_index].is_big_ship() ) {
if ( aip->targeted_subsys == NULL ) {
shipp->flags.set(Ship::Ship_Flags::Primary_linked);
if (!sip->flags[Ship::Info_Flags::No_primary_linking] ) {
shipp->flags.set(Ship::Ship_Flags::Primary_linked);
}
shipp->flags.set(Ship::Ship_Flags::Secondary_dual_fire);
return;
}
@@ -6052,8 +6041,7 @@ int check_ok_to_fire(int objnum, int target_objnum, weapon_info *wip)
// --------------------------------------------------------------------------
// Fire a secondary weapon.
// Maybe choose to fire a different one.
// priority1 and priority2 are optional parameters with defaults = -1
int ai_fire_secondary_weapon(object *objp, int priority1, int priority2)
int ai_fire_secondary_weapon(object *objp)
{
ship_weapon *swp;
ship *shipp;
@@ -6073,7 +6061,7 @@ int ai_fire_secondary_weapon(object *objp, int priority1, int priority2)
Assert( shipp->ship_info_index >= 0 && shipp->ship_info_index < static_cast<int>(Ship_info.size()));
// Select secondary weapon.
current_bank = swp->current_secondary_bank; //ai_select_secondary_weapon(objp, swp, priority1, priority2);
current_bank = swp->current_secondary_bank;
if (current_bank == -1) {
return rval;
@@ -6540,14 +6528,14 @@ void ai_chase_ct()
vm_vec_add2(&tvec, &Pl_objp->orient.vec.rvec);
}
ai_turn_towards_vector(&tvec, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&tvec, Pl_objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0);
accelerate_ship(aip, 1.0f);
}
/**
* ATTACK submode handler for chase mode.
*/
void ai_chase_eb(ai_info *aip, ship_info *sip, vec3d *predicted_enemy_pos, float dist_to_enemy)
static void ai_chase_eb(ai_info *aip, ship_info *sip, vec3d *predicted_enemy_pos)
{
vec3d _pep;
float dot_to_enemy, dot_from_enemy;
@@ -6559,7 +6547,7 @@ void ai_chase_eb(ai_info *aip, ship_info *sip, vec3d *predicted_enemy_pos, float
if ((dot_to_enemy > dot_from_enemy + 0.1f) || (dot_to_enemy > 0.9f))
vm_vec_scale_add(&_pep, &Pl_objp->pos, &En_objp->orient.vec.fvec, 100.0f);
ai_turn_towards_vector(&_pep, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&_pep, Pl_objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0);
accelerate_ship(aip, 0.0f);
}
@@ -6756,7 +6744,7 @@ void attack_set_accel(ai_info *aip, ship_info *sip, float dist_to_enemy, float d
// Pl_objp (aip) tries to get behind En_objp.
// New on 2/21/98: If this ship can move backwards and slide, maybe do that to get behind.
void get_behind_ship(ai_info *aip, ship_info *sip, float dist_to_enemy)
static void get_behind_ship(ai_info *aip, ship_info *sip)
{
vec3d new_pos;
float dot;
@@ -6765,7 +6753,7 @@ void get_behind_ship(ai_info *aip, ship_info *sip, float dist_to_enemy)
vm_vec_normalized_dir(&vec_from_enemy, &Pl_objp->pos, &En_objp->pos);
vm_vec_scale_add(&new_pos, &En_objp->pos, &En_objp->orient.vec.fvec, -100.0f); // Pick point 100 units behind.
ai_turn_towards_vector(&new_pos, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&new_pos, Pl_objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0);
dot = vm_vec_dot(&vec_from_enemy, &En_objp->orient.vec.fvec);
@@ -6784,7 +6772,7 @@ int avoid_player(object *objp, vec3d *goal_pos)
if (aip->ai_flags[AI::AI_Flags::Avoiding_small_ship]) {
ship_info *sip = &Ship_info[Ships[objp->instance].ship_info_index];
ai_turn_towards_vector(&aip->avoid_goal_point, objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&aip->avoid_goal_point, objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0);
accelerate_ship(aip, 0.5f);
return 1;
}
@@ -6982,7 +6970,7 @@ int maybe_avoid_big_ship(object *objp, object *ignore_objp, ai_info *aip, vec3d
vec3d v2g;
ai_turn_towards_vector(&aip->avoid_goal_point, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&aip->avoid_goal_point, Pl_objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0);
vm_vec_normalized_dir(&v2g, &aip->avoid_goal_point, &Pl_objp->pos);
float dot = vm_vec_dot(&objp->orient.vec.fvec, &v2g);
float d2 = (1.0f + dot) * (1.0f + dot);
@@ -7074,7 +7062,7 @@ void ai_stealth_find()
}
}
ai_turn_towards_vector(&new_pos, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&new_pos, Pl_objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0);
return;
}
@@ -7084,9 +7072,9 @@ void ai_stealth_find()
if (dist_to_enemy > 500.0f) {
vec3d rvec;
compute_desired_rvec(&rvec, &new_pos, &Pl_objp->pos);
ai_turn_towards_vector(&new_pos, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0, &rvec);
ai_turn_towards_vector(&new_pos, Pl_objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0, &rvec);
} else {
ai_turn_towards_vector(&new_pos, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&new_pos, Pl_objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0);
}
dot_from_enemy = -vm_vec_dot(&vec_to_enemy, &En_objp->orient.vec.fvec);
@@ -7214,7 +7202,7 @@ void ai_stealth_sweep()
return;
}
ai_turn_towards_vector(&goal_pt, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&goal_pt, Pl_objp, sip->srotation_time, nullptr, nullptr, 0.0f, 0);
float dot = 1.0f;
if (dist_to_goal < 100) {
@@ -7274,9 +7262,9 @@ void ai_chase_attack(ai_info *aip, ship_info *sip, vec3d *predicted_enemy_pos, f
if (dist_to_enemy > 500.0f) {
vec3d rvec;
compute_desired_rvec(&rvec, predicted_enemy_pos, &Pl_objp->pos);
ai_turn_towards_vector(&new_pos, Pl_objp, flFrametime, sip->srotation_time, NULL, rel_pos, bank_override, 0, &rvec);
ai_turn_towards_vector(&new_pos, Pl_objp, sip->srotation_time, nullptr, rel_pos, bank_override, 0, &rvec);
} else {
ai_turn_towards_vector(&new_pos, Pl_objp, flFrametime, sip->srotation_time, NULL, rel_pos, bank_override, 0);
ai_turn_towards_vector(&new_pos, Pl_objp, sip->srotation_time, nullptr, rel_pos, bank_override, 0);
}
attack_set_accel(aip, sip, dist_to_enemy, dot_to_enemy, dot_from_enemy);
@@ -7314,7 +7302,7 @@ void ai_chase_es(ai_info *aip, ship_info *sip)
float bank_override = Pl_objp->phys_info.speed;
ai_turn_towards_vector(&tvec, Pl_objp, flFrametime/2, sip->srotation_time, NULL, NULL, bank_override, 0);
ai_turn_towards_vector(&tvec, Pl_objp, sip->srotation_time, nullptr, nullptr, bank_override, 0);
accelerate_ship(aip, 1.0f);
}
@@ -7340,7 +7328,7 @@ void ai_chase_ga(ai_info *aip, ship_info *sip)
bank_override = Pl_objp->phys_info.speed;
ai_turn_towards_vector(&tvec, Pl_objp, flFrametime/2, sip->srotation_time, NULL, NULL, bank_override, 0);
ai_turn_towards_vector(&tvec, Pl_objp, sip->srotation_time, nullptr, nullptr, bank_override, 0);
accelerate_ship(aip, 2.0f);
@@ -7505,32 +7493,6 @@ void ai_set_guard_wing(object *objp, int wingnum)
}
}
// Make object *objp guard object *other_objp.
// To be called from the goals code.
void ai_set_evade_object(object *objp, object *other_objp)
{
ship *shipp;
ai_info *aip;
int other_objnum;
Assert(objp->type == OBJ_SHIP);
Assert(objp->instance >= 0);
shipp = &Ships[objp->instance];
Assert(shipp->ai_index >= 0);
aip = &Ai_info[shipp->ai_index];
other_objnum = OBJ_INDEX(other_objp);
Assert(other_objnum >= 0);
Assert(other_objnum != Ships[aip->shipnum].objnum); // make sure not targeting self
aip->target_objnum = other_objnum;
aip->mode = AIM_EVADE;
}
// Make objp guard other_objp
// If other_objp is a member of a wing, objp will guard that whole wing
// UNLESS objp is also a member of the wing!
@@ -8002,7 +7964,7 @@ void ai_cruiser_chase()
// kamikaze - ram and explode
if (aip->ai_flags[AI::AI_Flags::Kamikaze]) {
ai_turn_towards_vector(&En_objp->pos, Pl_objp, flFrametime, turn_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&En_objp->pos, Pl_objp, turn_time, nullptr, nullptr, 0.0f, 0);
accelerate_ship(aip, 1.0f);
}
@@ -8042,7 +8004,7 @@ void ai_cruiser_chase()
}
// now move as desired
ai_turn_towards_vector(&goal_pos, Pl_objp, flFrametime, turn_time, NULL, NULL, 0.0f, 0, rvecp);
ai_turn_towards_vector(&goal_pos, Pl_objp, turn_time, nullptr, nullptr, 0.0f, 0, rvecp);
accelerate_ship(aip, accel);
// maybe switch to new mode
@@ -8323,7 +8285,7 @@ void ai_chase()
break;
case SM_EVADE_BRAKE:
ai_chase_eb(aip, sip, &predicted_enemy_pos, dist_to_enemy);
ai_chase_eb(aip, sip, &predicted_enemy_pos);
break;
case SM_EVADE:
@@ -8335,7 +8297,7 @@ void ai_chase()
break;
case SM_GET_BEHIND:
get_behind_ship(aip, sip, dist_to_enemy);
get_behind_ship(aip, sip);
break;
case SM_GET_AWAY: // Used to get away from opponent to prevent endless circling.
@@ -8769,7 +8731,11 @@ void ai_chase()
scale = (scale - 0.6f) * 1.5f;
else
scale = 0.0f;
if (dist_to_enemy < pwip->max_speed * (1.0f + scale)) {
float range = pwip->max_speed * (1.0f + scale);
if (aip->ai_profile_flags[AI::Profile_Flags::Use_actual_primary_range]) {
range = std::min( {range, pwip->max_speed * pwip->lifetime, pwip->weapon_range} );
}
if (dist_to_enemy < range) {
if(ai_fire_primary_weapon(Pl_objp) == 1){
has_fired = 1;
}else{
@@ -9330,7 +9296,7 @@ float dock_orient_and_approach(object *docker_objp, int docker_index, object *do
{
float dot, accel;
float turn_time = Ship_info[Ships[docker_objp->instance].ship_info_index].srotation_time;
ai_turn_towards_vector(&goal_point, docker_objp, flFrametime, turn_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&goal_point, docker_objp, turn_time, nullptr, nullptr, 0.0f, 0);
dot = vm_vec_dot(&docker_objp->orient.vec.fvec, &away_vec);
accel = 0.1f;
@@ -9965,10 +9931,10 @@ void ai_big_guard()
}
// got the point, now let's go there
ai_turn_towards_vector(&goal_pt, Pl_objp, flFrametime, Ship_info[Ships[Pl_objp->instance].ship_info_index].srotation_time, NULL, NULL, 0.0f, 0);
ai_turn_towards_vector(&goal_pt, Pl_objp, Ship_info[Ships[Pl_objp->instance].ship_info_index].srotation_time, nullptr, nullptr, 0.0f, 0);
accelerate_ship(aip, 1.0f);
if ((aip->ai_flags[AI::AI_Flags::Free_afterburner_use]) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (cur_guard_rad > 1.1f * max_guard_dist)) {
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]) && (cur_guard_rad > 1.1f * max_guard_dist)) {
vec3d v2g;
float dot_to_goal_point;
@@ -10089,9 +10055,9 @@ void ai_guard()
// quite far away, so try to go straight to
compute_desired_rvec(&rvec, &goal_point, &Pl_objp->pos);
ai_turn_towards_vector(&goal_point, Pl_objp, flFrametime, Ship_info[shipp->ship_info_index].srotation_time, NULL, NULL, 0.0f, 0, &rvec);
ai_turn_towards_vector(&goal_point, Pl_objp, Ship_info[shipp->ship_info_index].srotation_time, nullptr, nullptr, 0.0f, 0, &rvec);
if ((aip->ai_flags[AI::AI_Flags::Free_afterburner_use]) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (accel_scale * (0.25f + dist_to_goal_point/700.0f) > 0.8f)) {
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_scale * (0.25f + dist_to_goal_point/700.0f) > 0.8f)) {
if (ai_maybe_fire_afterburner(Pl_objp, aip)) {
afterburners_start(Pl_objp);
aip->afterburner_stop_time = Missiontime + 3*F1_0;
@@ -10396,11 +10362,12 @@ void ai_get_dock_goal_indexes(object *objp, ai_info *aip, ai_goal *aigp, object
case AIS_DOCK_2:
case AIS_DOCK_3:
Warning(LOCATION, "Normally dock indexes should be calculated for only AIS_DOCK_0 and AIS_UNDOCK_0. Trace out and debug.");
FALLTHROUGH;
case AIS_DOCK_0:
{
// get them from the active goal
Assert(aigp != NULL);
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] || aigp->flags[AI::Goal_Flags::Docker_index_valid]);
Assert(aigp->flags[AI::Goal_Flags::Dockee_index_valid] && aigp->flags[AI::Goal_Flags::Docker_index_valid]);
docker_index = aigp->docker.index;
dockee_index = aigp->dockee.index;
Assert(docker_index >= 0);
@@ -10413,6 +10380,7 @@ void ai_get_dock_goal_indexes(object *objp, ai_info *aip, ai_goal *aigp, object
case AIS_UNDOCK_1:
case AIS_UNDOCK_2:
Warning(LOCATION, "Normally dock indexes should be calculated for only AIS_DOCK_0 and AIS_UNDOCK_0. Trace out and debug.");
FALLTHROUGH;
case AIS_UNDOCK_0:
{
// get them from the guy I'm docked to
@@ -10479,9 +10447,11 @@ void ai_cleanup_dock_mode_subjective(object *objp)
case AIS_UNDOCK_0:
model_anim_start_type(shipp, TRIGGER_TYPE_DOCKED, docker_index, -1);
model_anim_start_type(goal_shipp, TRIGGER_TYPE_DOCKED, dockee_index, -1);
FALLTHROUGH;
case AIS_UNDOCK_1:
model_anim_start_type(shipp, TRIGGER_TYPE_DOCKING_STAGE_3, docker_index, -1);
model_anim_start_type(goal_shipp, TRIGGER_TYPE_DOCKING_STAGE_3, dockee_index, -1);
FALLTHROUGH;
case AIS_UNDOCK_2:
model_anim_start_type(shipp, TRIGGER_TYPE_DOCKING_STAGE_2, docker_index, -1);
model_anim_start_type(goal_shipp, TRIGGER_TYPE_DOCKING_STAGE_2, dockee_index, -1);
@@ -10491,9 +10461,11 @@ void ai_cleanup_dock_mode_subjective(object *objp)
case AIS_DOCK_4A:
model_anim_start_type(shipp, TRIGGER_TYPE_DOCKED, docker_index, -1);
model_anim_start_type(goal_shipp, TRIGGER_TYPE_DOCKED, dockee_index, -1);
FALLTHROUGH;
case AIS_DOCK_3:
model_anim_start_type(shipp, TRIGGER_TYPE_DOCKING_STAGE_3, docker_index, -1);
model_anim_start_type(goal_shipp, TRIGGER_TYPE_DOCKING_STAGE_3, dockee_index, -1);
FALLTHROUGH;
case AIS_DOCK_2:
model_anim_start_type(shipp, TRIGGER_TYPE_DOCKING_STAGE_2, docker_index, -1);
model_anim_start_type(goal_shipp, TRIGGER_TYPE_DOCKING_STAGE_2, dockee_index, -1);
@@ -10708,8 +10680,8 @@ void ai_dock()
char *goal_ship_class_name = goal_sip->name;
char *goal_dock_path_name = model_get(goal_sip->model_num)->paths[aip->mp_index].name;
Warning(LOCATION, "Ship class %s has only %i points on dock path \"%s\". Recommended minimum number of points is 4. "\
"Docking along that path will look strange. You may wish to edit the model.", goal_ship_class_name, aip->path_length, goal_dock_path_name);
mprintf(("Ship class %s has only %i points on dock path \"%s\". Recommended minimum number of points is 4. "\
"Docking along that path will look strange. You may wish to edit the model.", goal_ship_class_name, aip->path_length, goal_dock_path_name));
}
aip->submode = AIS_DOCK_1;
@@ -10834,7 +10806,7 @@ void ai_dock()
if (aip->submode == AIS_DOCK_3) {
// Play a ship docking attach sound
snd_play_3d( &Snds[SND_DOCK_ATTACH], &Pl_objp->pos, &View_position );
snd_play_3d( gamesnd_get_game_sound(GameSounds::DOCK_ATTACH), &Pl_objp->pos, &View_position );
// start the dock animation
model_anim_start_type(shipp, TRIGGER_TYPE_DOCKED, docker_index, 1);
@@ -10961,7 +10933,7 @@ void ai_dock()
ai_find_path(Pl_objp, OBJ_INDEX(goal_objp), path_num, 0);
// Play a ship docking detach sound
snd_play_3d( &Snds[SND_DOCK_DETACH], &Pl_objp->pos, &View_position );
snd_play_3d( gamesnd_get_game_sound(GameSounds::DOCK_DETACH), &Pl_objp->pos, &View_position );
aip->submode = AIS_UNDOCK_1;
aip->submode_start_time = Missiontime;
@@ -10981,7 +10953,7 @@ void ai_dock()
// play the depart sound, but only once, since this mode is called multiple times per frame
if ( !(aigp->flags[AI::Goal_Flags::Depart_sound_played]))
{
snd_play_3d( &Snds[SND_DOCK_DEPART], &Pl_objp->pos, &View_position );
snd_play_3d( gamesnd_get_game_sound(GameSounds::DOCK_DEPART), &Pl_objp->pos, &View_position );
aigp->flags.set(AI::Goal_Flags::Depart_sound_played);
}
@@ -11380,7 +11352,7 @@ float gwlr_1(object *objp, ai_info *aip)
/**
* Compute the largest radius of a ship forming on *objp's wing.
*/
float gwlr_object_1(object *objp, ai_info *aip)
static float gwlr_object_1(object *objp)
{
float max_radius;
object *o;
@@ -11413,7 +11385,7 @@ float get_wing_largest_radius(object *objp, int formation_object_flag)
aip = &Ai_info[shipp->ai_index];
if (formation_object_flag) {
return gwlr_object_1(objp, aip);
return gwlr_object_1(objp);
} else {
return gwlr_1(objp, aip);
}
@@ -11555,53 +11527,6 @@ void render_wing_phantoms_all()
#endif
// Hook from goals code to AI.
// Force a wing to fly in formation.
// Sets AIF_FORMATION bit in ai_flags.
// wingnum Wing to force to fly in formation
void ai_fly_in_formation(int wingnum)
{
object *objp;
ship *shipp;
ship_obj *so;
for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) ) {
objp = &Objects[so->objnum];
Assert((objp->instance >= 0) && (objp->instance < MAX_SHIPS));
shipp = &Ships[objp->instance];
Assert((shipp->ai_index >= 0) && (shipp->ai_index < MAX_AI_INFO));
if (Ai_info[shipp->ai_index].wing == wingnum) {
Ai_info[shipp->ai_index].ai_flags.set(AI::AI_Flags::Formation_wing);
Ai_info[shipp->ai_index].ai_flags.remove(AI::AI_Flags::Formation_object);
}
}
}
// Hook from goals code to AI.
// Force a wing to abandon formation flying.
// Clears AIF_FORMATION bit in ai_flags.
// wingnum Wing to force to fly in formation
void ai_disband_formation(int wingnum)
{
object *objp;
ship *shipp;
ship_obj *so;
for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) ) {
objp = &Objects[so->objnum];
Assert((objp->instance >= 0) && (objp->instance < MAX_SHIPS));
shipp = &Ships[objp->instance];
Assert((shipp->ai_index >= 0) && (shipp->ai_index < MAX_AI_INFO));
if (Ai_info[shipp->ai_index].wing == wingnum) {
Ai_info[shipp->ai_index].ai_flags.remove(AI::AI_Flags::Formation_wing);
}
}
}
float Leader_chaos = 0.0f;
int Chaos_frame = -1;
@@ -11803,7 +11728,7 @@ int ai_formation()
ship_info *sip = &Ship_info[shipp->ship_info_index];
bool ab_allowed = false;
if ((sip->flags[Ship::Info_Flags::Afterburner]) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (aip->ai_flags[AI::AI_Flags::Free_afterburner_use])) {
if ((sip->flags[Ship::Info_Flags::Afterburner]) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (aip->ai_flags[AI::AI_Flags::Free_afterburner_use] || aip->ai_profile_flags[AI::Profile_Flags::Free_afterburner_use])) {
ab_allowed = true;
} else {
if (Pl_objp->phys_info.flags & PF_AFTERBURNER_ON)
@@ -12186,7 +12111,7 @@ void ai_maybe_launch_cmeasure(object *objp, ai_info *aip)
}
// --------------------------------------------------------------------------
void ai_preprocess_ignore_objnum(object *objp, ai_info *aip)
static void ai_preprocess_ignore_objnum(ai_info *aip)
{
if (aip->ai_flags[AI::AI_Flags::Temporary_ignore])
{
@@ -12377,6 +12302,7 @@ void ai_maybe_evade_locked_missile(object *objp, ai_info *aip)
case AIM_DOCK: // Ships in dock mode can evade iif they are not currently repairing or docked.
if (object_is_docked(objp) || (aip->ai_flags[AI::AI_Flags::Repairing, AI::AI_Flags::Being_repaired]))
break;
FALLTHROUGH;
case AIM_GUARD:
// If in guard mode and far away from guard object, don't pursue guy that hit me.
if ((aip->guard_objnum != -1) && (aip->guard_signature == Objects[aip->guard_objnum].signature)) {
@@ -12384,6 +12310,7 @@ void ai_maybe_evade_locked_missile(object *objp, ai_info *aip)
return;
}
}
FALLTHROUGH;
case AIM_EVADE:
case AIM_GET_BEHIND:
case AIM_STAY_NEAR:
@@ -13017,7 +12944,7 @@ void ai_execute_behavior(ai_info *aip)
ship *shipp = &Ships[aip->shipnum];
ship_info *sip = &Ship_info[shipp->ship_info_index];
if (strnicmp(shipp->ship_name, INSTRUCTOR_SHIP_NAME, strlen(INSTRUCTOR_SHIP_NAME))) {
if (strnicmp(shipp->ship_name, INSTRUCTOR_SHIP_NAME, strlen(INSTRUCTOR_SHIP_NAME)) != 0) {
if (sip->is_big_or_huge()) {
aip->mode = AIM_NONE;
} else {
@@ -13057,7 +12984,6 @@ void ai_execute_behavior(ai_info *aip)
case AIM_NONE:
break;
case AIM_BIGSHIP:
ai_big_ship(Pl_objp);
break;
case AIM_PATH: {
int path_num;
@@ -13375,7 +13301,7 @@ void ai_warp_out(object *objp)
case AIS_WARP_2: // Make sure won't collide with any object.
if (timestamp_elapsed(aip->force_warp_time)
|| (!collide_predict_large_ship(objp, objp->radius*2.0f + 100.0f)
|| (Ship_info[shipp->ship_info_index].warpout_type == WT_HYPERSPACE
|| (Warp_params[shipp->warpout_params_index].warp_type == WT_HYPERSPACE
&& !collide_predict_large_ship(objp, 100000.0f)))) {
aip->submode = AIS_WARP_3;
aip->submode_start_time = Missiontime;
@@ -13418,7 +13344,7 @@ void ai_warp_out(object *objp)
break;
case AIS_WARP_4: {
// Only lets the ship warp after waiting for the warpout engage time
if ( (Missiontime / 100) >= (aip->submode_start_time / 100 + Ship_info[shipp->ship_info_index].warpout_engage_time) ) {
if ( (Missiontime / 100) >= (aip->submode_start_time / 100 + Warp_params[shipp->warpout_params_index].warpout_engage_time) ) {
shipfx_warpout_start(objp);
aip->submode = AIS_WARP_5;
aip->submode_start_time = Missiontime;
@@ -13434,7 +13360,7 @@ void ai_warp_out(object *objp)
// Return object index of weapon that could produce a shockwave that should be known about to *objp.
// Return nearest one.
int ai_find_shockwave_weapon(object *objp, ai_info *aip)
static int ai_find_shockwave_weapon(const object *objp)
{
missile_obj *mo;
float nearest_dist = 999999.9f;
@@ -13500,7 +13426,7 @@ void ai_announce_ship_dying(object *dying_objp)
// Return object index of weapon that could produce a shockwave that should be known about to *objp.
// Return nearest one.
int ai_find_shockwave_ship(object *objp, ai_info *aip)
static int ai_find_shockwave_ship(object *objp)
{
ship_obj *so;
float nearest_dist = 999999.9f;
@@ -13543,7 +13469,7 @@ int aas_1(object *objp, ai_info *aip, vec3d *safe_pos)
// If we don't currently know of a weapon to avoid, try to find one.
// If we can't find one, then clear the bit so we don't keep coming here.
if (aip->shockwave_object == -1) {
int shockwave_weapon = ai_find_shockwave_weapon(objp, aip);
int shockwave_weapon = ai_find_shockwave_weapon(objp);
if (shockwave_weapon == -1) {
aip->ai_flags.remove(AI::AI_Flags::Avoid_shockwave_weapon);
return 0;
@@ -13632,7 +13558,7 @@ int aas_1(object *objp, ai_info *aip, vec3d *safe_pos)
}
} else if (aip->ai_flags[AI::AI_Flags::Avoid_shockwave_ship]) {
if (aip->shockwave_object == -1) {
int shockwave_ship = ai_find_shockwave_ship(objp, aip);
int shockwave_ship = ai_find_shockwave_ship(objp);
if (shockwave_ship == -1) {
aip->ai_flags.remove(AI::AI_Flags::Avoid_shockwave_ship);
return 0;
@@ -13862,7 +13788,7 @@ int maybe_big_ship_collide_recover_frame(object *objp, ai_info *aip)
vec3d v2g;
if (aip->ai_flags[AI::AI_Flags::Big_ship_collide_recover_1]) {
ai_turn_towards_vector(&aip->big_recover_pos_1, objp, flFrametime, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, NULL, NULL, 0.0f, 0, NULL);
ai_turn_towards_vector(&aip->big_recover_pos_1, objp, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, nullptr, nullptr, 0.0f, 0, nullptr);
dist = vm_vec_normalized_dir(&v2g, &aip->big_recover_pos_1, &objp->pos);
dot = vm_vec_dot(&objp->orient.vec.fvec, &v2g);
accelerate_ship(aip, dot);
@@ -13876,7 +13802,7 @@ int maybe_big_ship_collide_recover_frame(object *objp, ai_info *aip)
return 1;
} else if (aip->ai_flags[AI::AI_Flags::Big_ship_collide_recover_2]) {
ai_turn_towards_vector(&aip->big_recover_pos_2, objp, flFrametime, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, NULL, NULL, 0.0f, 0, NULL);
ai_turn_towards_vector(&aip->big_recover_pos_2, objp, Ship_info[Ships[objp->instance].ship_info_index].srotation_time, nullptr, nullptr, 0.0f, 0, nullptr);
dist = vm_vec_normalized_dir(&v2g, &aip->big_recover_pos_2, &objp->pos);
dot = vm_vec_dot(&objp->orient.vec.fvec, &v2g);
accelerate_ship(aip, dot);
@@ -13996,7 +13922,7 @@ void ai_frame(int objnum)
if (maybe_big_ship_collide_recover_frame(Pl_objp, aip))
return;
ai_preprocess_ignore_objnum(Pl_objp, aip);
ai_preprocess_ignore_objnum(aip);
target_objnum = set_target_objnum(aip, aip->target_objnum);
Assert(objnum != target_objnum);
@@ -14151,7 +14077,7 @@ void ai_frame(int objnum)
}
}
void ai_control_info_check( object *obj, ai_info *aip )
static void ai_control_info_check(ai_info *aip)
{
if(aip->ai_override_flags.none_set())
return;
@@ -14252,7 +14178,7 @@ void ai_process( object * obj, int ai_index, float frametime )
if (rfc == 1) {
// Wanderer - sexp based override goes here - only if rfc is valid though
ai_control_info_check(obj, aip);
ai_control_info_check(aip);
vec3d copy_desired_rotvel = obj->phys_info.rotvel;
physics_read_flying_controls( &obj->orient, &obj->phys_info, &AI_ci, frametime);
// if obj is in formation and not flight leader, don't update rotvel
@@ -14787,10 +14713,10 @@ int firing_aspect_seeking_bomb(object *objp)
return 0;
}
// *objp collided with big ship *big_objp at global point *collide_pos
// Make it fly away from the collision point.
// *objp collided with big ship *big_objp at some global point.
// Make it fly away from the collision point.
// collision_normal is NULL, when a collision is imminent and we just want to bug out.
void big_ship_collide_recover_start(object *objp, object *big_objp, vec3d *collide_pos, vec3d *collision_normal)
void big_ship_collide_recover_start(object *objp, object *big_objp, vec3d *collision_normal)
{
ai_info *aip;
@@ -14879,9 +14805,9 @@ void ai_update_lethality(object *pship_obj, object *other_obj, float damage)
/**
* Object *objp_ship was hit by either weapon *objp_weapon or collided into by ship hit_objp at point *hitpos.
* Object *objp_ship was hit by either weapon *objp_weapon or collided into by ship hit_objp
*/
void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_quadrant, vec3d *hit_normal)
void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hit_normal)
{
int hitter_objnum = -2;
object *objp_hitter = NULL;
@@ -14923,7 +14849,7 @@ void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_
// And the current object is _not_ a big ship
if (!Ship_info[Ships[objp_ship->instance].ship_info_index].is_big_or_huge()) {
// Recover from hitting a big ship. Note, if two big ships collide, they just pound away at each other. Oh well. Recovery looks dumb and it's very late.
big_ship_collide_recover_start(objp_ship, hit_objp, hitpos, hit_normal);
big_ship_collide_recover_start(objp_ship, hit_objp, hit_normal);
}
}
}
@@ -15060,7 +14986,7 @@ void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_
return;
if ( (hit_objp->type == OBJ_WEAPON) && !(aip->ai_flags[AI::AI_Flags::No_dynamic]) ) {
if ( ai_big_maybe_enter_strafe_mode(objp_ship, OBJ_INDEX(hit_objp), 1) )
if ( ai_big_maybe_enter_strafe_mode(objp_ship, OBJ_INDEX(hit_objp)) )
return;
}
break;
@@ -15180,10 +15106,7 @@ void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_
// Ship shipnum has been destroyed.
// Cleanup.
// the parameter 'method' is used to tell is this ship was destroyed or it departed normally.
// This function will get called in either case, and there are things that should be done if
// the ship actually gets destroyed which shouldn't get done if it departed.
void ai_ship_destroy(int shipnum, Ship::Exit_Flags method)
void ai_ship_destroy(int shipnum)
{
int objnum;
object *other_objp;
@@ -15434,7 +15357,7 @@ int ai_issue_rearm_request(object *requester_objp)
// we aren't able to do anything!
else {
Assert(result == 4);
Assertion(false, "This case should have already been caught by the is_support_allowed precheck!");
UNREACHABLE("This case should have already been caught by the is_support_allowed precheck!");
return -1;
}
}
@@ -15503,7 +15426,7 @@ int ai_return_path_num_from_dockbay(object *dockee_objp, int dockbay_index)
/**
* Actually go ahead and fire the synaptics.
*/
void cheat_fire_synaptic(object *objp, ship *shipp, ai_info *aip)
static void cheat_fire_synaptic(object *objp, ship *shipp)
{
ship_weapon *swp;
swp = &shipp->weapons;
@@ -15525,7 +15448,7 @@ void cheat_fire_synaptic(object *objp, ship *shipp, ai_info *aip)
// if they're near one or more enemies
// every so often
// fire a synaptic if they have one.
void maybe_cheat_fire_synaptic(object *objp, ai_info *aip)
void maybe_cheat_fire_synaptic(object *objp)
{
// Only do in subspace missions.
if (!(The_mission.flags[Mission::Mission_Flags::Subspace]))
@@ -15557,7 +15480,7 @@ void maybe_cheat_fire_synaptic(object *objp, ai_info *aip)
int count = num_nearby_fighters(iff_get_attackee_mask(obj_team(objp)), &objp->pos, 1500.0f);
if (count > 0)
cheat_fire_synaptic(objp, shipp, aip);
cheat_fire_synaptic(objp, shipp);
}
}
}
+59 -52
View File
@@ -62,31 +62,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 +126,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
@@ -414,7 +415,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 +427,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 +733,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 +944,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 +1138,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 +1279,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 +1356,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 )
{
@@ -1401,7 +1398,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
@@ -1640,7 +1637,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
}
else
{
Int3(); // get ALLENDER
mprintf(("Potentially incorrect behaviour in AI goal for ship %s: Ship %s could not be found among currently active, departed, or yet-to-arrive ships.\nPlease check the mission file.\n", Ships[objp->instance].ship_name, aigp->target_name));
status = SHIP_STATUS_UNKNOWN;
}
}
@@ -1895,9 +1892,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 +2290,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
+14 -12
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)
@@ -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);
@@ -1874,7 +1876,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 +2011,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,10 +2050,10 @@ 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( &Snds[wip->launch_snd], turret_pos, &View_position );
snd_play_3d( gamesnd_get_game_sound(wip->launch_snd), turret_pos, &View_position );
}
}
}
@@ -2126,7 +2128,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,10 +2137,10 @@ 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( &Snds[Weapon_info[tsi->weapon_class].launch_snd], &turret_pos, &View_position );
snd_play_3d( gamesnd_get_game_sound(Weapon_info[tsi->weapon_class].launch_snd), &turret_pos, &View_position );
}
}
+7 -167
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
@@ -733,6 +720,10 @@ anim *anim_load(const char *real_filename, int cf_dir_type, int file_mapped)
anim_read_header(ptr, fp);
if (ptr->width < 0 || ptr->height < 0) {
Error(LOCATION, "Ani file %s has a faulty header and cannot be loaded.", name);
}
if(ptr->num_keys > 0){
ptr->keys = (key_frame*)vm_malloc(sizeof(key_frame) * ptr->num_keys);
Assert(ptr->keys != NULL);
@@ -761,7 +752,7 @@ anim *anim_load(const char *real_filename, int cf_dir_type, int file_mapped)
}
// couldn't memory-map file... must be in a packfile, so stream manually
if ( file_mapped && !ptr->cfile_ptr ) {
if ( file_mapped == PAGE_FROM_MEM && !ptr->cfile_ptr ) {
ptr->flags &= ~ANF_MEM_MAPPED;
ptr->flags |= ANF_STREAMED;
ptr->cfile_ptr = cfopen(name, "rb", CFILE_NORMAL, cf_dir_type);
@@ -862,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?
@@ -892,133 +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);
// 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;
@@ -1052,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;
+3 -10
View File
@@ -40,9 +40,8 @@ typedef struct {
enum
{
PAGE_FROM_MEM = 0,
PAGE_FROM_DISK = 1,
PAGE_FROM_DISK_FORCED = 2
PAGE_FROM_DISK = 0,
PAGE_FROM_MEM = 1
};
extern int Anim_paused;
@@ -55,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_MEM);
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);
+16 -363
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
@@ -512,7 +151,14 @@ int unpack_pixel(anim_instance *ai, ubyte *data, ubyte pix, int aabitmap, int bp
bit_16 = (ushort)pix;
break;
case 8:
bit_8 = pix;
// 8 bit-per-pixel aa bitmaps are a bit special since they only use value in the range [0, 15] where 15 wraps
// around back to 0. Since the rest of the code expects the value to be in the range [0, 255] the pixel value
// needs to be adjusted here. By muliplying the value with 17 the original range [0, 15] is mapped to [0, 255]
if (pix >= 15) {
bit_8 = 0;
} else {
bit_8 = (ubyte)(pix * 17);
}
break;
default:
Int3();
@@ -596,7 +242,14 @@ int unpack_pixel_count(anim_instance *ai, ubyte *data, ubyte pix, int count = 0,
bit_16 = (ushort)pix;
break;
case 8 :
bit_8 = pix;
// 8 bit-per-pixel aa bitmaps are a bit special since they only use value in the range [0, 15] where 15 wraps
// around back to 0. Since the rest of the code expects the value to be in the range [0, 255] the pixel value
// needs to be adjusted here. By muliplying the value with 17 the original range [0, 15] is mapped to [0, 255]
if (pix >= 15) {
bit_8 = 0;
} else {
bit_8 = (ubyte)(pix * 17);
}
break;
default :
Int3();
-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);
+49 -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;
@@ -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,37 +1274,37 @@ 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;
}
snd_play_3d( &Snds[sound_index], &objp->pos, &Eye_position, objp->radius, NULL, 0, 1.0f, SND_PRIORITY_MUST_PLAY, NULL, range_factor );
snd_play_3d( gamesnd_get_game_sound(sound_index), &objp->pos, &Eye_position, objp->radius, NULL, 0, 1.0f, SND_PRIORITY_MUST_PLAY, NULL, range_factor );
}
/**
* 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;
@@ -1568,8 +1523,12 @@ void asteroid_maybe_break_up(object *pasteroid_obj)
vec3d tempv = dir_vec;
vm_vec_random_cone(&dir_vec, &tempv, (360.0f / total_roids / 2));
// Make the roid inherit half of the parent's velocity
vm_vec_copy_normalize(&parent_vel, &pasteroid_obj->phys_info.vel);
// Make the roid inherit half of parent's directional movement
if (!IS_VEC_NULL(&pasteroid_obj->phys_info.vel)) {
vm_vec_copy_normalize(&parent_vel, &pasteroid_obj->phys_info.vel);
} else {
vm_vec_rand_vec_quick(&parent_vel);
}
vm_vec_scale(&parent_vel, 0.5f);
// Make the hit position affect the direction, but only a little
@@ -1586,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;
@@ -1652,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);
@@ -1670,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;
@@ -1692,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;
@@ -1731,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 ) {
@@ -1811,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);
@@ -1911,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];
@@ -2062,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;
@@ -2086,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);
+3 -49
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)
{
@@ -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);
+38 -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
@@ -31,6 +41,7 @@ union bm_extra_info {
int keyframe; //!< used for animations -- keyframe info
float total_time; //!< used for animations -- total animation time (not always derived from num_frames/fps)
ubyte fps; //!< used for animations -- frames per second
bool is_array; //!< Flag for if all frames of an animation have the same size which means that it can be put into a texture array
struct {
// stuff for static animations
@@ -56,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
@@ -89,17 +98,35 @@ struct bitmap_entry {
#endif
};
extern bitmap_entry bm_bitmaps[MAX_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__
+882 -836
View File
File diff suppressed because it is too large. Load diff
+74 -100
View File
@@ -32,21 +32,6 @@
* @{
*/
/**
* @brief How many bitmaps the game can handle
*
* @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 MAX_BITMAPS 4750
// 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
@@ -56,6 +41,7 @@
#define BMP_TEX_DXT3 (1<<4) //!< dxt3 compressed 8r8g8b4a (32bit)
#define BMP_TEX_DXT5 (1<<5) //!< dxt5 compressed 8r8g8b8a (32bit)
#define BMP_TEX_CUBEMAP (1<<6) //!< a texture made for cubic environment map
#define BMP_MASK_BITMAP (1<<7) //!< a bitmap that will be used for masking mouse interaction. Typically not used in render operations
// Combined flags
#define BMP_TEX_COMP ( BMP_TEX_DXT1 | BMP_TEX_DXT3 | BMP_TEX_DXT5 ) //!< Compressed textures
@@ -112,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.
@@ -123,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
@@ -140,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)
@@ -193,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);
};
@@ -337,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
*/
@@ -409,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()
*
@@ -434,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
*
@@ -501,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
*
@@ -558,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
*
@@ -575,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
*
@@ -603,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
@@ -623,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
@@ -698,4 +603,73 @@ bool bm_load_and_parse_eff(const char *filename, int dir_type, int *nframes, int
*/
int bm_get_anim_frame(const int frame1_handle, float elapsed_time, const float divisor = 0.0f, const bool loop = false);
/**
* @brief Determines if the given handle could be used in a texture array
*
* @param handle The handle to query the value for
* @return @c true if all frames have the same size, @c false otherwise. Always returns @c true for single images
*/
bool bm_is_texture_array(const int handle);
/**
* @brief Gets the base frame of the specified animation
*
* @details The base frame is the frame of the animation that should be used to determine if two animation frames can be
* used in the same draw call. Use this if you want to optimize your draw calls to make use of texture arrays.
*
* @param handle The handle of the animation to check. This may also be a single frame bitmap
* @param num_frames Optionally return the number of frames in the animation
* @return The bitmap handle of the base frame or -1 on error
*/
int bm_get_base_frame(const int handle, int* num_frames = nullptr);
/**
* @brief Get the array index of the specified bitmap
*
* This should be used when passing the array index to the GPU (e.g. when building uniform structs or streaming particle
* data)
*
* @param handle The handle of the bitmap
* @return The index into the array
*/
int bm_get_array_index(const int handle);
/**
* @brief Counts how many slots are used in bm_bitmaps
*
* This needs to iterate through all the slots in order to determine whether or not they're used, so shouldn't be used frivolously.
*
* @return The number of used slots
*/
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
*
* @note At least one of @c single_frame or @c animation must be true since the result would make no sense otherwise. It
* is also valid to set both parmeters to @c true.
*
* @todo This currently just tries to load the file but could be improved by not actually loading the file in the future.
*
* @param file The file name to check
* @param single_frame If set to @c true then single frames are valid files
* @param animation If set to @c true then animations are valid files
* @return @c true if the file name is valid, @c false otherwise
*/
bool bm_validate_filename(const SCP_string& file, bool single_frame, bool animation);
SDL_Surface* bm_to_sdl_surface(int handle);
#endif
+25 -19
View File
@@ -2,14 +2,15 @@
#include "globalincs/alphacolors.h"
#include "globalincs/linklist.h"
#include "globalincs/systemvars.h" //VM_FREECAMERA etc
#include "graphics/font.h"
#include "graphics/matrix.h"
#include "hud/hud.h" //hud_get_draw
#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();
+253 -389
View File
File diff suppressed because it is too large. Load diff
+150 -60
View File
@@ -13,10 +13,11 @@
#define __CFILE_H__
#include <time.h>
#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 {
@@ -78,9 +77,12 @@ typedef struct {
#define CF_TYPE_INTEL_ANIMS 34
#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 37 // 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))
@@ -94,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.
@@ -108,54 +165,52 @@ extern const char *Get_file_list_child;
// cfile directory. valid after cfile_init() returns successfully
#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
namespace cfile {
enum class ModRootType { Unknown, Folder, Package };
enum class LocationType { Unknown, SecondaryMod, PrimaryMod, GameRoot };
struct ModRoot {
ModRootType type = ModRootType::Unknown;
SCP_string path;
LocationType location_type = LocationType::Unknown;
bool user_location = false;
};
} // namespace cfile
//================= LOW-LEVEL FUNCTIONS ==================
int cfile_init(const char *exe_dir, const char *cdrom_dir=NULL);
int cfile_init(const SCP_vector<cfile::ModRoot>& modRoots);
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)
// NOTE: only supports reading files!!
CFILE *_cfopen_special(const char* source_file, int line, const char *file_path, const char *mode,
const size_t size, const size_t offset, int dir_type = CF_TYPE_ANY);
const size_t size, const size_t offset, const void* data, int dir_type = CF_TYPE_ANY);
#define cfopen_special(...) _cfopen_special(LOCATION, __VA_ARGS__) // Pass source location to the function
// 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);
@@ -189,10 +244,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);
@@ -215,7 +266,7 @@ char *cfgets(char *buf, int n, CFILE *cfile);
int cfeof(CFILE *cfile);
// Return the data pointer associated with the CFILE structure (for memory mapped files)
void *cf_returndata(CFILE *cfile);
const void *cf_returndata(CFILE *cfile);
// get the 2 byte checksum of the passed filename - return 0 if operation failed, 1 if succeeded
int cf_chksum_short(const char *filename, ushort *chksum, int max_size = -1, int cf_type = CF_TYPE_ANY );
@@ -244,7 +295,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
@@ -262,17 +312,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.
@@ -288,6 +336,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);
@@ -296,8 +351,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);
@@ -310,12 +363,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
@@ -325,7 +392,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);
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.
@@ -339,7 +416,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);
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);
@@ -354,6 +432,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
@@ -364,16 +444,13 @@ namespace cfile
{
}
cfile_error(const std::string &excuse) : m_excuse(excuse)
explicit cfile_error(const std::string &excuse) : m_excuse(excuse)
{
}
~cfile_error() throw()
{
}
~cfile_error() SCP_NOEXCEPT override {}
virtual const char *what() const throw()
{
const char *what() const SCP_NOEXCEPT override {
return m_excuse.c_str();
}
@@ -384,7 +461,7 @@ namespace cfile
class max_read_length : public cfile_error
{
public:
max_read_length(const std::string &excuse) : cfile_error(excuse)
explicit max_read_length(const std::string &excuse) : cfile_error(excuse)
{
}
@@ -395,4 +472,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__ */
+89 -82
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,25 +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;
result = 0;
// cfeof() not supported for memory-mapped files
Assert( !cb->data );
Assert(cb->fp != NULL);
int result = 0;
#if defined(CHECK_POSITION) && !defined(NDEBUG)
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;
@@ -105,24 +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];
// Doesn't work for memory mapped files
Assert( !cb->data );
Assert(cb->fp != NULL);
#if defined(CHECK_POSITION) && !defined(NDEBUG)
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;
}
@@ -135,40 +116,48 @@ 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->data );
Assert( cb->fp != NULL );
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();
return 1;
}
}
int result = fseek(cb->fp, (long)goal_position, SEEK_SET );
cb->raw_position = goal_position - cb->lib_offset;
// Make sure we don't seek beyond the end of the file
CAP(goal_position, cfile->lib_offset, cfile->lib_offset + cfile->size);
int result = 0;
if (cfile->fp) {
// If we have a file pointer we can also seek in that file
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
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)
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
return result;
@@ -190,25 +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];
// cfread() not supported for memory-mapped files
if(cb->data != NULL)
{
Warning(LOCATION, "Writing is not supported for mem-mapped files");
return 0;
}
if ( (cb->raw_position+size) > cb->size ) {
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";
@@ -216,14 +197,24 @@ int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
}
}
size_t bytes_read = fread( buf, 1, size, cb->fp );
size_t bytes_read;
if (cfile->data != nullptr) {
// This is a file from memory
bytes_read = size;
memcpy(buf, reinterpret_cast<const char*>(cfile->data) + cfile->raw_position, size);
} else {
bytes_read = fread( buf, 1, size, cfile->fp );
}
if ( bytes_read > 0 ) {
cb->raw_position += bytes_read;
cfile->raw_position += bytes_read;
Assertion(cfile->raw_position <= cfile->size, "Invalid raw_position value detected!");
}
#if defined(CHECK_POSITION) && !defined(NDEBUG)
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
return (int)(bytes_read / elsize);
@@ -238,22 +229,38 @@ 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;
}
long orig_pos = ftell(cb->fp);
int items_read = fscanf(cb->fp, LUA_NUMBER_SCAN, buf);
cb->raw_position += ftell(cb->fp)-orig_pos;
size_t advance = 0;
int items_read;
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*>(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;
}
cfile->raw_position += advance;
Assertion(cfile->raw_position <= cfile->size, "Invalid raw_position value detected!");
#if defined(CHECK_POSITION) && !defined(NDEBUG)
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
return items_read;
+14 -14
View File
@@ -22,30 +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
void *data; // Pointer for memory-mapped file access. NULL if not mem-mapped.
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;
}
}
+266
View File
@@ -0,0 +1,266 @@
#define _CFILE_INTERNAL
#include "cfilemod.h"
#include "cfile.h"
#include "cmdline/cmdline.h"
#include "osapi/osapi.h"
#include "cfilesystem.h"
#ifdef SCP_UNIX
#include <glob.h>
#include <sys/types.h>
#include <dirent.h>
#include <fnmatch.h>
#include <sys/stat.h>
#include <unistd.h>
#include <libgen.h>
#endif
namespace cfile {
namespace {
typedef struct cf_root_sort {
SCP_string path;
int cf_type;
} cf_root_sort;
// packfile sort function
bool cf_packfile_sort_func(const cf_root_sort& r1, const cf_root_sort& r2) {
// if the 2 directory types are the same, do a string compare
if (r1.cf_type == r2.cf_type) {
return (stricmp(r1.path.c_str(), r2.path.c_str()) < 0);
}
// otherwise return them in order of CF_TYPE_* precedence
return (r1.cf_type < r2.cf_type);
}
// Go through a root and look for pack files
void build_pack_list(SCP_vector<ModRoot>& mod_roots,
const SCP_string& search_path,
LocationType location_type,
bool user_location) {
char filespec[MAX_PATH_LEN];
// allocate a temporary array of temporary roots so we can easily sort them
SCP_vector<cf_root_sort> temp_roots_sort;
// now just setup all the root info
for (int i = CF_TYPE_ROOT; i < CF_MAX_PATH_TYPES; i++) {
strcpy_s(filespec, search_path.c_str());
if (strlen(Pathtypes[i].path)) {
strcat_s(filespec, Pathtypes[i].path);
if (filespec[strlen(filespec) - 1] != DIR_SEPARATOR_CHAR)
strcat_s(filespec, DIR_SEPARATOR_STR);
}
#if defined _WIN32
strcat_s( filespec, "*.vp" );
intptr_t find_handle;
_finddata_t find;
find_handle = _findfirst( filespec, &find );
if (find_handle != -1) {
do {
// add the new item
if (!(find.attrib & _A_SUBDIR)) {
// get a temp pointer
rptr_sort = &temp_roots_sort[root_index++];
// fill in all the proper info
strcpy_s(rptr_sort->path, root->path);
if(strlen(Pathtypes[i].path)) {
strcat_s(rptr_sort->path, Pathtypes[i].path );
strcat_s(rptr_sort->path, DIR_SEPARATOR_STR);
}
strcat_s(rptr_sort->path, find.name );
rptr_sort->roottype = CF_ROOTTYPE_PACK;
rptr_sort->cf_type = i;
}
} while (!_findnext(find_handle, &find));
_findclose( find_handle );
}
#elif defined SCP_UNIX
strcat_s(filespec, "*.[vV][pP]");
glob_t globinfo;
memset(&globinfo, 0, sizeof(globinfo));
int status = glob(filespec, 0, NULL, &globinfo);
if (status == 0) {
for (uint j = 0; j < globinfo.gl_pathc; j++) {
// Determine if this is a regular file
struct stat statbuf;
memset(&statbuf, 0, sizeof(statbuf));
stat(globinfo.gl_pathv[j], &statbuf);
if (S_ISREG(statbuf.st_mode)) {
cf_root_sort sort;
// fill in all the proper info
sort.path = globinfo.gl_pathv[j];
sort.cf_type = i;
temp_roots_sort.push_back(sort);
}
}
globfree(&globinfo);
}
#endif
}
// sort the roots
std::sort(temp_roots_sort.begin(), temp_roots_sort.end(), cf_packfile_sort_func);
// now insert them all into the real root list properly
for (const auto& pack_root : temp_roots_sort) {
ModRoot root;
root.type = ModRootType::Package;
root.path = pack_root.path;
root.user_location = user_location;
root.location_type = location_type;
mod_roots.push_back(root);
}
}
char normalize_directory_separator(char in) {
if (in == '/') {
return DIR_SEPARATOR_CHAR;
}
return in;
}
void
add_mod_roots(SCP_vector<ModRoot>& mod_roots, const char* mod_cmdline, const SCP_string& rootDirectory, bool user_location) {
if (mod_cmdline) {
bool primary = true;
for (const char* cur_pos = mod_cmdline; strlen(cur_pos) != 0; cur_pos += (strlen(cur_pos) + 1)) {
SCP_stringstream ss;
ss << rootDirectory;
if (rootDirectory.back() != DIR_SEPARATOR_CHAR) {
ss << DIR_SEPARATOR_CHAR;
}
ss << cur_pos << DIR_SEPARATOR_STR;
SCP_string rootPath = ss.str();
// normalize the path to the native path format
std::transform(rootPath.begin(), rootPath.end(), rootPath.begin(), normalize_directory_separator);
ModRoot root;
root.type = ModRootType::Folder;
root.path = rootPath;
root.user_location = user_location;
if (primary) {
root.location_type = LocationType::PrimaryMod;
} else {
root.location_type = LocationType::SecondaryMod;
}
mod_roots.push_back(root);
build_pack_list(mod_roots, rootPath, root.location_type, user_location);
primary = false;
}
}
}
}
SCP_vector<ModRoot> getModRootsFromModCmdline(const SCP_string& content_root, const char* mod_cmdline) {
SCP_vector<ModRoot> mod_roots;
if (os_is_legacy_mode()) {
// =========================================================================
#ifdef WIN32
// Nothing to do here, Windows uses the current directory as the base
#else
add_mod_roots(mod_roots, mod_cmdline, os_get_legacy_user_dir(), true);
ModRoot root;
root.type = ModRootType::Folder;
root.path = os_get_legacy_user_dir();
root.user_location = true;
root.location_type = LocationType::GameRoot;
// do we already have a slash? as in the case of a root directory install
if (root.path.back() != DIR_SEPARATOR_CHAR) {
root.path += DIR_SEPARATOR_STR; // put trailing backslash on for easier path construction
}
mod_roots.push_back(root);
// Next, check any VP files under the current directory.
build_pack_list(mod_roots, root.path, root.location_type, root.user_location);
#endif
// =========================================================================
} else if (!Cmdline_portable_mode) {
// =========================================================================
// now look for mods under the users HOME directory to use before system ones
add_mod_roots(mod_roots, mod_cmdline, os_get_config_path(), true);
// =========================================================================
// =========================================================================
// set users HOME directory as default for loading and saving files
ModRoot root;
root.type = ModRootType::Folder;
root.path = os_get_config_path();
root.user_location = true;
root.location_type = LocationType::GameRoot;
// do we already have a slash? as in the case of a root directory install
if (root.path.back() != DIR_SEPARATOR_CHAR) {
root.path += DIR_SEPARATOR_STR; // put trailing backslash on for easier path construction
}
mod_roots.push_back(root);
// Next, check any VP files under the current directory.
build_pack_list(mod_roots, root.path, root.location_type, root.user_location);
// =========================================================================
}
add_mod_roots(mod_roots, mod_cmdline, content_root, false);
ModRoot root;
root.type = ModRootType::Folder;
root.path = content_root;
root.user_location = false;
root.location_type = LocationType::GameRoot;
// do we already have a slash? as in the case of a root directory install
if (root.path.back() != DIR_SEPARATOR_CHAR) {
root.path += DIR_SEPARATOR_STR; // put trailing backslash on for easier path construction
}
mod_roots.push_back(root);
//======================================================
// Next, check any VP files under the current directory.
build_pack_list(mod_roots, root.path, root.location_type, root.user_location);
return mod_roots;
}
}
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#include "globalincs/pstypes.h"
#include "cfile/cfile.h"
namespace cfile {
SCP_vector<ModRoot> getModRootsFromModCmdline(const SCP_string& content_root, const char* mod_cmdline);
}
+527 -526
View File
File diff suppressed because it is too large. Load diff
+7 -3
View File
@@ -15,7 +15,7 @@
#include "cfile/cfile.h"
// Builds a list of all the files
void cf_build_secondary_filelist( const char *cdrom_path );
void cf_build_secondary_filelist(const SCP_vector<cfile::ModRoot>& modRoots);
void cf_free_secondary_filelist();
// Internal stuff
@@ -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
+1 -1
View File
@@ -8,7 +8,7 @@ set_target_properties(cfilearchiver
PROPERTIES
FOLDER "FSOTools"
)
TARGET_LINK_LIBRARIES(cfilearchiver PUBLIC ${SDL_LIBS})
TARGET_LINK_LIBRARIES(cfilearchiver PUBLIC sdl2)
TARGET_INCLUDE_DIRECTORIES(cfilearchiver PUBLIC ${GENERATED_SOURCE_DIR})
TARGET_INCLUDE_DIRECTORIES(cfilearchiver PUBLIC ${GENERATED_SOURCE_DIR}/code)
+10 -31
View File
@@ -315,28 +315,16 @@ int verify_directory( char *filespec )
void print_instructions()
{
printf( "Creates a vp archive out of a FreeSpace data tree.\n\n" );
printf( "Usage: cfilearchiver archive_name src_dir\n");
printf( "Example: cfilearchiver freespace /tmp/freespace/data\n\n");
printf( "Directory structure options:\n" );
printf( " Effects (.ani .pcx .neb .tga)\n" );
printf( " Fonts (.vf)\n" );
printf( " Hud (.ani .pcx .tga\n" );
printf( " Interface (.pcx .ani .tga)\n" );
printf( " Maps (.pcx .ani .tga)\n" );
printf( " Missions (.ntl .ssv), FS1(.fsm .fsc), FS2(.fs2 .fc2)\n" );
printf( " Models (.pof)\n" );
printf( " Music (.wav)\n" );
printf( " Sounds/8b22k (.wav)\n" );
printf( " Sounds/16b11k (.wav)\n" );
printf( " Tables (.tbl)\n" );
printf( " Voice/Briefing (.wav)\n" );
printf( " Voice/Command briefings (.wav)\n" );
printf( " Voice/Debriefing (.wav)\n" );
printf( " Voice/Personas (.wav)\n" );
printf( " Voice/Special (.wav)\n" );
printf( " Voice/Training (.wav)\n" );
printf("Creates a vp archive out of a FreeSpace data tree.\n\n");
printf("Usage: cfilearchiver archive_name src_dir\n");
#ifdef _WIN32
printf("Example: cfilearchiver freespace c:\\freespace\\data\n");
#else
printf("Example: cfilearchiver freespace /tmp/freespace/data\n\n");
#endif
printf("Creates an archive named freespace out of the freespace data tree\n");
printf("For information about the FS2 directory structure, please consult\n");
printf("http://www.hard-light.net/wiki/index.php/FS2_Data_Structure\n");
exit(0);
}
@@ -352,16 +340,7 @@ int main(int argc, char *argv[] )
char *p;
if ( argc < 3 ) {
#ifdef _WIN32
printf( "Usage: %s archive_name src_dir\n", argv[0] );
printf( "Example: %s freespace c:\\freespace\\data\n", argv[0] );
printf( "Creates an archive named freespace out of the\nfreespace data tree\n" );
printf( "Press any key to exit...\n" );
getch();
return 1;
#else
print_instructions();
#endif
}
strcpy_s( archive, argv[1] );
+1 -1
View File
@@ -8,7 +8,7 @@ set_target_properties(cfileextractor
PROPERTIES
FOLDER "FSOTools"
)
TARGET_LINK_LIBRARIES(cfileextractor PUBLIC ${SDL_LIBS})
TARGET_LINK_LIBRARIES(cfileextractor PUBLIC sdl2)
TARGET_INCLUDE_DIRECTORIES(cfileextractor PUBLIC ${GENERATED_SOURCE_DIR})
TARGET_INCLUDE_DIRECTORIES(cfileextractor PUBLIC ${GENERATED_SOURCE_DIR}/code)
+735 -337
View File
File diff suppressed because it is too large. Load diff
+22 -28
View File
@@ -12,6 +12,7 @@
#ifndef FS_CMDLINE_HEADER_FILE
#define FS_CMDLINE_HEADER_FILE
#include "globalincs/pstypes.h"
int parse_cmdline(int argc, char *argv[]);
@@ -24,11 +25,11 @@ int parse_cmdline(int argc, char *argv[]);
// RETAIL OPTIONS ----------------------------------------------
extern char *Cmdline_connect_addr;
extern char *Cmdline_game_name;
extern char *Cmdline_game_password;
extern char *Cmdline_rank_above;
extern char *Cmdline_rank_below;
extern SCP_string Cmdline_connect_addr;
extern SCP_string Cmdline_game_name;
extern SCP_string Cmdline_game_password;
extern SCP_string Cmdline_rank_above;
extern SCP_string Cmdline_rank_below;
extern int Cmdline_cd_check;
extern int Cmdline_client_dodamage;
extern int Cmdline_closed_game;
@@ -46,8 +47,8 @@ extern int Cmdline_timeout;
extern int Cmdline_use_last_pilot;
extern int Cmdline_window;
extern int Cmdline_fullscreen_window;
extern char *Cmdline_res;
extern char *Cmdline_center_res;
extern SCP_string Cmdline_res;
extern SCP_string Cmdline_center_res;
// FSO OPTIONS -------------------------------------------------
@@ -55,35 +56,25 @@ extern char *Cmdline_center_res;
// 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_missile_lighting;
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 bool Cmdline_no_batching;
extern int Cmdline_shadow_quality;
extern int Cmdline_no_deferred_lighting;
extern int Cmdline_no_emissive;
extern int Cmdline_aniso_level;
// Game Speed related
extern int Cmdline_cache_bitmaps;
extern int Cmdline_NoFPSCap;
extern int Cmdline_no_vsync;
@@ -103,19 +94,21 @@ extern int Cmdline_autopilot_interruptable;
extern int Cmdline_stretch_menu;
// Audio related
extern int Cmdline_query_speech;
extern int Cmdline_snd_preload;
extern int Cmdline_voice_recognition;
extern int Cmdline_no_enhanced_sound;
namespace cfile {
struct ModRoot;
} // namespace cfile
// MOD related
extern char *Cmdline_mod; // DTP for mod support
extern SCP_vector<cfile::ModRoot> Cmdline_mod; // DTP for mod support
// Multiplayer/Network related
extern char *Cmdline_almission; // DTP for autoload mission (for multi only)
extern SCP_string 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 SCP_string Cmdline_spew_mission_crcs;
extern SCP_string Cmdline_spew_table_crcs;
extern int Cmdline_objupd;
// Launcher related options
@@ -131,7 +124,7 @@ extern int Cmdline_mipmap;
extern int Cmdline_ati_color_swap;
extern int Cmdline_no_3d_sound;
extern int Cmdline_drawelements;
extern char* Cmdline_keyboard_layout;
extern SCP_string Cmdline_keyboard_layout;
extern bool Cmdline_gl_finish;
extern bool Cmdline_no_geo_sdr_effects;
extern bool Cmdline_set_cpu_affinity;
@@ -142,12 +135,13 @@ extern bool Cmdline_alternate_registry_path;
#endif
// Developer/Testing related
extern char *Cmdline_start_mission;
extern int Cmdline_old_collision_sys;
extern SCP_string Cmdline_start_mission;
extern int Cmdline_dis_collisions;
extern int Cmdline_dis_weapons;
extern bool Cmdline_output_sexp_info;
extern int Cmdline_noparseerrors;
extern int Cmdline_extra_warn;
extern int Cmdline_bmpman_usage;
extern int Cmdline_show_pos;
extern int Cmdline_show_stats;
extern int Cmdline_save_render_targets;
@@ -157,9 +151,9 @@ 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;
#endif
+48
View File
@@ -0,0 +1,48 @@
{
"version": 1,
"flags": {
"-bool_option": false,
"-number_option": 5.8,
"-string_option": "asdf",
"-mod": [
{
"type": "folder",
"path": "/home/fso/mediavps",
"user": true,
"location_type": "primary_mod"
},
{
"type": "folder",
"path": "/home/fso",
"user": true,
"location_type": "game_root"
},
{
"type": "folder",
"path": "/path/to/fso/mediavps",
"user": false,
"location_type": "primary_mod"
},
{
"type": "package",
"path": "/path/to/fso/mediavps/MVPS-Z.vp",
"location_type": "primary_mod"
},
{
"type": "package",
"path": "/path/to/fso/mediavps/MVPS-X.vp",
"location_type": "primary_mod"
},
{
"type": "folder",
"path": "/path/to/fso",
"location_type": "game_root"
},
{
"type": "package",
"path": "/path/to/fso/retail.vp",
"location_type": "game_root"
}
]
}
}
+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(&Snds[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
+61 -83
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;
@@ -615,7 +609,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 +658,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 +709,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 +717,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 +725,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 +749,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 +760,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 +770,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 +781,7 @@ int control_config_clear_other()
}
if (!total) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -808,7 +802,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 +814,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 +844,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 +861,7 @@ int control_config_clear_all()
}
if (!total) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -888,7 +882,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 +939,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 +975,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;
}
@@ -1026,10 +1020,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 +1036,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 +1053,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 +1070,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 +1085,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 +1112,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 +1136,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 +1160,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 +1183,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 +1200,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 +1231,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 +1244,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 +1275,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 +1793,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 +1804,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 +1819,7 @@ void control_config_do_frame(float frametime)
}
}
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
break;
case KEY_RIGHT:
@@ -1837,7 +1831,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 +1867,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()) {
@@ -1974,7 +1968,7 @@ void control_config_do_frame(float frametime)
if (t % 2) {
gr_set_color_fast(&Color_text_normal);
gr_get_string_size(&w, NULL, XSTR( "?", 208));
gr_printf_menu(x - w / 2, y - font_height / 2, XSTR( "?", 208));
gr_printf_menu(x - w / 2, y - font_height / 2, "%s", XSTR( "?", 208));
}
} else if (!(z & JOY_AXIS) && ((Conflicts[z].key >= 0) || (Conflicts[z].joy >= 0))) {
@@ -1986,7 +1980,7 @@ void control_config_do_frame(float frametime)
gr_set_color_fast(&Color_text_normal);
str = XSTR( "Control conflicts with:", 209);
gr_get_string_size(&w, NULL, str);
gr_printf_menu(x - w / 2, y - font_height, str);
gr_printf_menu(x - w / 2, y - font_height, "%s", str);
if (Control_config[i].hasXSTR) {
strcpy_s(buf, XSTR(Control_config[i].text, CONTROL_CONFIG_XSTR + i));
@@ -1996,12 +1990,12 @@ void control_config_do_frame(float frametime)
font::force_fit_string(buf, 255, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
gr_get_string_size(&w, NULL, buf);
gr_printf_menu(x - w / 2, y, buf);
gr_printf_menu(x - w / 2, y, "%s", buf);
} else if (*bound_string) {
gr_set_color_fast(&Color_text_normal);
gr_get_string_size(&w, NULL, bound_string);
gr_printf_menu(x - w / 2, y - font_height / 2, bound_string);
gr_printf_menu(x - w / 2, y - font_height / 2, "%s", bound_string);
if (timestamp_elapsed(bound_timestamp)) {
*bound_string = 0;
}
@@ -2009,7 +2003,7 @@ void control_config_do_frame(float frametime)
if (Cc_lines[Num_cc_lines - 1].y + font_height > Cc_lines[Scroll_offset].y + Control_list_coords[gr_screen.res][CONTROL_H_COORD]) {
gr_set_color_fast(&Color_white);
gr_printf_menu(Control_more_coords[gr_screen.res][CONTROL_X_COORD], Control_more_coords[gr_screen.res][CONTROL_Y_COORD], XSTR( "More...", 210));
gr_printf_menu(Control_more_coords[gr_screen.res][CONTROL_X_COORD], Control_more_coords[gr_screen.res][CONTROL_Y_COORD], "%s", XSTR( "More...", 210));
}
conflict = 0;
@@ -2035,7 +2029,7 @@ void control_config_do_frame(float frametime)
if (Cc_lines[line].label) {
strcpy_s(buf, Cc_lines[line].label);
font::force_fit_string(buf, 255, Control_list_ctrl_w[gr_screen.res]);
gr_printf_menu(Control_list_coords[gr_screen.res][CONTROL_X_COORD], y, buf);
gr_printf_menu(Control_list_coords[gr_screen.res][CONTROL_X_COORD], y, "%s", buf);
}
if (!(z & JOY_AXIS)) {
@@ -2046,7 +2040,7 @@ void control_config_do_frame(float frametime)
if ((k < 0) && (j < 0)) {
gr_set_color_fast(&Color_grey);
gr_printf_menu(x, y, XSTR( "None", 211));
gr_printf_menu(x, y, "%s", XSTR( "None", 211));
} else {
if (k >= 0) {
@@ -2066,7 +2060,7 @@ void control_config_do_frame(float frametime)
gr_set_color_fast(c);
}
gr_printf_menu(x, y, buf);
gr_printf_menu(x, y, "%s", buf);
Cc_lines[line].kx = x - Control_list_coords[gr_screen.res][CONTROL_X_COORD];
gr_get_string_size(&w, NULL, buf);
@@ -2075,7 +2069,7 @@ void control_config_do_frame(float frametime)
if (j >= 0) {
gr_set_color_fast(&Color_text_normal);
gr_printf_menu(x, y, XSTR( ", ", 212));
gr_printf_menu(x, y, "%s", XSTR( ", ", 212));
gr_get_string_size(&w, NULL, XSTR( ", ", 212));
x += w;
}
@@ -2099,7 +2093,7 @@ void control_config_do_frame(float frametime)
}
font::force_fit_string(buf, 255, Control_list_key_w[gr_screen.res] + Control_list_key_x[gr_screen.res] - x);
gr_printf_menu(x, y, buf);
gr_printf_menu(x, y, "%s", buf);
Cc_lines[line].jx = x - Control_list_coords[gr_screen.res][CONTROL_X_COORD];
gr_get_string_size(&Cc_lines[line].jw, NULL, buf);
@@ -2115,7 +2109,7 @@ void control_config_do_frame(float frametime)
if (j < 0) {
gr_set_color_fast(&Color_grey);
gr_printf_menu(x, y, XSTR( "None", 211));
gr_printf_menu(x, y, "%s", XSTR( "None", 211));
} else {
if (Conflicts_axes[z & ~JOY_AXIS] >= 0) {
@@ -2193,17 +2187,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;
@@ -2345,7 +2328,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 +2362,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 +2402,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 +2430,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;
}
}
+19 -7
View File
@@ -277,12 +277,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[];
@@ -311,13 +305,31 @@ void control_config_cancel_exit();
void control_config_reset_defaults(int presetnum=-1);
int translate_key_to_index(const char *key, bool find_override=true);
char *translate_key(char *key);
/**
* @brief Converts the specified key code to a human readable string
*
* @note The returned value is localized to the current language
*
* @param code The key code to convert
* @return The text representation of the code. The returned value is stored in a temporary location, copy it to your
* own buffer if you want to continue using it.
*/
const char *textify_scancode(int code);
/**
* @note Same as textify_scancode but always returns the same value regardless of current language
* @param code The key code to convert
* @return The name of the key
* @see textify_scancode
*/
const char *textify_scancode_universal(int code);
float check_control_timef(int id);
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();
+30 -38
View File
@@ -7,8 +7,8 @@
*
*/
#include <stdio.h>
#include <stdarg.h>
#include <cstdio>
#include <cstdarg>
#include "cfile/cfile.h"
#include "controlconfig/controlsconfig.h"
@@ -34,13 +34,6 @@ int Failed_key_index;
int Joy_dead_zone_size = 10;
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;
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 };
@@ -201,7 +194,7 @@ config_item Control_config[CCFG_MAX + 1] = {
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 +244,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 +403,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 +504,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
@@ -586,6 +556,28 @@ const char *textify_scancode(int code)
strcat_s(text, Scan_code_text[keycode]);
return text;
}
const char *textify_scancode_universal(int code)
{
if (code < 0)
return "None";
int keycode = code & KEY_MASK;
static char text[40];
*text = 0;
if (code & KEY_ALTED && !(keycode == KEY_LALT || keycode == KEY_RALT)) {
strcat_s(text, "Alt-");
}
if (code & KEY_SHIFTED && !(keycode == KEY_LSHIFT || keycode == KEY_RSHIFT)) {
strcat_s(text, "Shift-");
}
// Always use the english version here
strcat_s(text, Scan_code_text_english[keycode]);
return text;
}
//XSTR:ON
void control_config_common_load_overrides();
+22 -6
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) {
}
@@ -14,6 +20,11 @@ bool Decoder::tryPopAudioData(AudioFramePtr& out) {
return res == queue_op_status::success;
}
bool Decoder::tryPopSubtitleData(SubtitleFramePtr& out) {
auto res = m_subtitleQueue->try_pull_front(out);
return res == queue_op_status::success;
}
bool Decoder::tryPopVideoFrame(VideoFramePtr& out) {
auto res = m_videoQueue->try_pull_front(out);
return res == queue_op_status::success;
@@ -24,6 +35,7 @@ void Decoder::initializeQueues(size_t queueSize) {
m_videoQueue.reset(new sync_bounded_queue<VideoFramePtr>(m_queueSize));
m_audioQueue.reset(new sync_bounded_queue<AudioFramePtr>(m_queueSize));
m_subtitleQueue.reset(new sync_bounded_queue<SubtitleFramePtr>(m_queueSize));
}
void Decoder::stopDecoder() {
@@ -31,10 +43,7 @@ void Decoder::stopDecoder() {
m_videoQueue->close();
m_audioQueue->close();
}
bool Decoder::canPushAudioData() {
return !isAudioQueueFull();
m_subtitleQueue->close();
}
void Decoder::pushAudioData(AudioFramePtr&& data) {
@@ -48,8 +57,15 @@ void Decoder::pushAudioData(AudioFramePtr&& data) {
}
}
bool Decoder::canPushVideoData() {
return !isVideoQueueFull();
void Decoder::pushSubtitleData(SubtitleFramePtr&& data) {
Assertion(data, "Invalid audio data passed!");
try {
m_subtitleQueue->push_back(std::move(data));
}
catch (sync_queue_is_closed&) {
// Ignore
}
}
void Decoder::pushFrameData(VideoFramePtr&& frame) {
+42 -17
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 {
@@ -58,6 +65,19 @@ struct AudioFrame {
};
typedef std::unique_ptr<AudioFrame> AudioFramePtr;
struct SubtitleFrame {
double displayStartTime = -1.0;
double displayEndTime = -1.0;
SCP_string text;
};
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
*
@@ -68,6 +88,7 @@ class Decoder {
private:
std::unique_ptr<sync_bounded_queue<VideoFramePtr>> m_videoQueue;
std::unique_ptr<sync_bounded_queue<AudioFramePtr>> m_audioQueue;
std::unique_ptr<sync_bounded_queue<SubtitleFramePtr>> m_subtitleQueue;
bool m_decoding;
size_t m_queueSize = 0;
@@ -90,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
@@ -107,7 +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() const = 0;
/**
* @brief Ends decoding of the video file
@@ -122,6 +145,10 @@ class Decoder {
bool tryPopAudioData(AudioFramePtr&);
bool isSubtitleQueueFull() { return m_subtitleQueue->size() == m_queueSize; }
bool tryPopSubtitleData(SubtitleFramePtr&);
bool isVideoQueueFull() { return m_videoQueue->size() == m_queueSize; }
bool isVideoFrameAvailable() { return !m_videoQueue->empty(); }
@@ -137,11 +164,9 @@ class Decoder {
protected:
void initializeQueues(size_t queueSize);
bool canPushAudioData();
void pushAudioData(AudioFramePtr&& data);
bool canPushVideoData();
void pushSubtitleData(SubtitleFramePtr&& data);
void pushFrameData(VideoFramePtr&& frame);
};
+138
View File
@@ -0,0 +1,138 @@
#include "VideoPresenter.h"
#include "graphics/matrix.h"
using namespace cutscene;
using namespace cutscene::player;
namespace {
struct movie_vertex {
vec2d pos;
vec2d uv;
};
}
namespace cutscene {
namespace player {
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);
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);
_planeTextureBuffers[1].reset(new uint8_t[w / 2 * h / 2]);
_planeTextureHandles[1] = bm_create(8, w / 2, h / 2, _planeTextureBuffers[1].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(&_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");
for (auto& handle : _planeTextureHandles) {
if (handle > 0) {
bm_release(handle);
handle = -1;
}
}
}
void VideoPresenter::uploadVideoFrame(const VideoFramePtr& frame) {
GR_DEBUG_SCOPE("Update video frame");
for (size_t i = 0; i < frame->getPlaneNumber(); ++i) {
auto size = frame->getPlaneSize(i);
auto data = frame->getPlaneData(i);
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) {
GR_DEBUG_SCOPE("Draw video frame");
movie_vertex vertex_data[4];
vertex_data[0].pos.x = x1;
vertex_data[0].pos.y = y1;
vertex_data[0].uv.x = 0.0f;
vertex_data[0].uv.y = 0.0f;
vertex_data[1].pos.x = x1;
vertex_data[1].pos.y = y2;
vertex_data[1].uv.x = 0.0f;
vertex_data[1].uv.y = 1.0f;
vertex_data[2].pos.x = x2;
vertex_data[2].pos.y = y1;
vertex_data[2].uv.x = 1.0f;
vertex_data[2].uv.y = 0.0f;
vertex_data[3].pos.x = x2;
vertex_data[3].pos.y = y2;
vertex_data[3].uv.x = 1.0f;
vertex_data[3].uv.y = 1.0f;
// Use the immediate buffer for storing our data since that is exactly what we need
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]), offsetof(movie_vertex, pos));
layout.add_vertex_component(vertex_format_data::TEX_COORD2, sizeof(vertex_data[0]), offsetof(movie_vertex, uv));
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);
}
}
}
}
+39
View File
@@ -0,0 +1,39 @@
#ifndef FS2_OPEN_OPENGLVIDEOPRESENTER_H
#define FS2_OPEN_OPENGLVIDEOPRESENTER_H
#include "globalincs/pstypes.h"
#include "graphics/2d.h"
#include "graphics/material.h"
#include "cutscene/Decoder.h"
#include <memory>
namespace cutscene {
namespace player {
class VideoPresenter {
MovieProperties _properties;
std::array<int, 3> _planeTextureHandles;
std::array<std::unique_ptr<uint8_t[]>, 3> _planeTextureBuffers;
movie_material _movie_material;
material _rgb_material; // Material used when a RGB/RGBA movie is played
public:
explicit VideoPresenter(const MovieProperties& props);
// Disallow copying
VideoPresenter(const VideoPresenter&) = delete;
VideoPresenter& operator=(const VideoPresenter&) = delete;
virtual ~VideoPresenter();
void uploadVideoFrame(const VideoFramePtr& frame);
void displayFrame(float x1, float y1, float x2, float y2);
};
}
}
#endif //FS2_OPEN_OPENGLVIDEOPRESENTER_H
+13 -13
View File
@@ -286,10 +286,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 +302,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 +328,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 +349,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 +361,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 +388,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;
@@ -585,7 +585,7 @@ void cutscenes_screen_do_frame()
}
gr_printf_menu(Cutscene_list_coords[gr_screen.res][0], Cutscene_list_coords[gr_screen.res][1] + y,
Cutscenes[Cutscene_list[z]].name);
"%s", Cutscenes[Cutscene_list[z]].name);
y += font_height;
z++;
-8
View File
@@ -21,15 +21,7 @@ typedef struct cutscene_info
bool viewable;
} 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();
+6
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
}
@@ -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);
}
}
}
+5 -3
View File
@@ -25,11 +25,13 @@ class AudioDecoder: public FFMPEGStreamDecoder<AudioFrame> {
public:
explicit AudioDecoder(DecoderStatus* status);
virtual ~AudioDecoder();
~AudioDecoder() override;
virtual void decodePacket(AVPacket* packet) SCP_OVERRIDE;
void decodePacket(AVPacket* packet) override;
virtual void finishDecoding() SCP_OVERRIDE;
void finishDecoding() override;
void flushBuffers() override;
};
}
}
+398 -75
View File
@@ -9,6 +9,10 @@
#include "cutscene/ffmpeg/AudioDecoder.h"
#include "cutscene/ffmpeg/VideoDecoder.h"
#include "cutscene/ffmpeg/SubtitleDecoder.h"
#include "FFMPEGDecoder.h"
#include "localization/localize.h"
using namespace libs::ffmpeg;
@@ -24,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)
{
@@ -55,23 +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;
#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;
#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";
}
// 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";
}
/**
* @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;
}
}
}
@@ -118,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();
@@ -136,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"));
}
}
}
@@ -155,7 +265,59 @@ std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream>& st
status->audioStream = ctx->streams[audioStream];
}
status->videoCodecPars = getCodecParameters(status->videoStream);
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];
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;
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;
}
auto normalized_language = normalizeLanguage(tag->value);
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)
@@ -213,6 +375,38 @@ std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream>& st
status->audioCodec->name ? status->audioCodec->name : "<Unknown>"));
}
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);
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(57, 24, 255)
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;
}
#else
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));
}
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;
}
@@ -231,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];
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('.');
@@ -250,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;
}
@@ -261,42 +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;
if (hasAudio()) {
audioDecoder.reset(new AudioDecoder(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];
@@ -308,56 +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));
}
} else if (audioDecoder && packet.stream_index == m_status->audioStreamIndex) {
audioDecoder->decodePacket(&packet);
AudioFramePtr ptr;
while ((ptr = audioDecoder->getFrame()) != nullptr) {
pushAudioData(std::move(ptr));
SubtitleFramePtr ptr;
while ((ptr = decoder->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;
}
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;
}
}
}
}
+19 -7
View File
@@ -8,26 +8,38 @@ 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();
virtual ~FFMPEGDecoder();
~FFMPEGDecoder() override;
bool initialize(const SCP_string& fileName) SCP_OVERRIDE;
bool initialize(const SCP_string& fileName, const PlaybackProperties& properties) override;
MovieProperties getProperties() SCP_OVERRIDE;
MovieProperties getProperties() const override;
void startDecoding() SCP_OVERRIDE;
void startDecoding() override;
bool hasAudio() SCP_OVERRIDE;
bool hasAudio() const override;
void close() SCP_OVERRIDE;
bool hasSubtitles() const override;
void close() override;
};
}
}
+138
View File
@@ -0,0 +1,138 @@
//
//
#include "SubtitleDecoder.h"
namespace {
double getFrameTime(int64_t pts, AVRational time_base) {
return pts * av_q2d(time_base);
}
}
namespace cutscene {
namespace ffmpeg {
SubtitleDecoder::SubtitleDecoder(cutscene::ffmpeg::DecoderStatus* status) : FFMPEGStreamDecoder(status) {
}
SubtitleDecoder::~SubtitleDecoder() {
}
void SubtitleDecoder::decodePacket(AVPacket* packet) {
int finishedFrame = 0;
AVSubtitle subtitle;
auto result = avcodec_decode_subtitle2(m_status->subtitleCodecCtx, &subtitle, &finishedFrame, packet);
if (result >= 0 && finishedFrame) {
pushSubtitleFrame(packet, &subtitle);
avsubtitle_free(&subtitle);
}
}
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) {
// Non-text subtitles are not supported yet.
mprintf(("FFmpeg: Detected a non-text subtitle! This is not supported yet!\n"));
return;
}
if (subtitle->num_rects < 1) {
return;
}
int64_t pts = subtitle->pts;
if (pts == AV_NOPTS_VALUE) {
pts = packet->pts;
}
if (pts == AV_NOPTS_VALUE) {
// Still no valid timestamp...
return;
}
auto packet_time = getFrameTime(pts, m_status->subtitleStream->time_base);
auto start_time = packet_time + (subtitle->start_display_time / 1000.0);
auto end_time = packet_time + (subtitle->end_display_time / 1000.0);
if (subtitle->end_display_time == 0 && m_status->subtitleStream->time_base.num != 0) {
end_time = packet_time + getFrameTime(packet->duration, m_status->subtitleStream->time_base);
}
SCP_string processed_text;
// For now we only use the first subtitle rectangle
auto subtitle_rect = subtitle->rects[0];
if (subtitle_rect->type == SUBTITLE_BITMAP) {
// Same as above, non-text subtitles are not supported yet.
mprintf(("FFmpeg: Detected a non-text subtitle! This is not supported yet!\n"));
return;
} else if (subtitle_rect->type == SUBTITLE_TEXT) {
// Subtitle does not need to be processed any further
processed_text = subtitle_rect->text;
} else if (subtitle_rect->type == SUBTITLE_ASS) {
SCP_string ass_text = subtitle_rect->ass;
// We are not interested in any of the other information contained in the ASS line but we still need to figure
// out where our text starts
auto comma_pos = ass_text.find(',');
for (auto i = 0; i < 8 && comma_pos != SCP_string::npos; ++i) {
comma_pos = ass_text.find(',', comma_pos + 1);
}
Assertion(comma_pos != SCP_string::npos, "Received an ill-formed ASS line from FFmpeg! Text was '%s'.", subtitle_rect->ass);
// This + 1 is safe since comma_pos points to a valid character so the next character is at worst the end of the string
processed_text = ass_text.substr(comma_pos + 1);
// ASS has a special sequence for new lines that needs to be converted to an actual new line
auto newline_pos = processed_text.find("\\N");
while(newline_pos != SCP_string::npos) {
processed_text.replace(newline_pos, 2, "\n");
newline_pos = processed_text.find("\\N");
}
} else {
mprintf(("FFmpeg: Detected unknown subtitle name in movie!\n"));
return;
}
// Remove \r from string. Some subtitles use \r\n for line breaks and we only support \n
auto ret_pos = processed_text.find('\r');
while(ret_pos != SCP_string::npos) {
processed_text.erase(ret_pos, 1);
ret_pos = processed_text.find('\r');
}
SubtitleFramePtr frame(new SubtitleFrame());
frame->text = processed_text;
frame->displayStartTime = start_time;
frame->displayEndTime = end_time;
pushFrame(std::move(frame));
}
void SubtitleDecoder::flushBuffers() {
avcodec_flush_buffers(m_status->subtitleCodecCtx);
}
}
}
+25
View File
@@ -0,0 +1,25 @@
#pragma once
#include "cutscene/ffmpeg/internal.h"
#include "cutscene/ffmpeg/FFMPEGDecoder.h"
namespace cutscene {
namespace ffmpeg {
class SubtitleDecoder: public FFMPEGStreamDecoder<SubtitleFrame> {
public:
explicit SubtitleDecoder(DecoderStatus* status);
~SubtitleDecoder() override;
void decodePacket(AVPacket* packet) override;
void finishDecoding() override;
void pushSubtitleFrame(AVPacket* subtitle, AVSubtitle* pSubtitle);
void flushBuffers() override;
};
}
}
+62 -63
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;
virtual ~FFMPEGVideoFrame() {
if (frame != nullptr) {
av_freep(&frame->data[0]);
av_frame_free(&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);
}
}
virtual DataPointers getDataPointers() {
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);
}
}
}
Loaded 100 of 1319 files, more files were not shown because too many files have changed in this diff. Show more