Compare commits

..
Author SHA1 Message Date
asarium 131d22c82a 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-06 19:55:28 +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
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 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
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
asarium 5258066545 Validate number of parsed briefing stages and icons
This fixes two possible assertions and two possible buffer overflows
which could have been caused by a mission with wrong values for
$num_stages and $num_icons.

This fixes #1664.
2018-03-18 15:50:10 +01:00
asarium 55c1c3ce9d Fix wrong handle return type 2018-03-16 23:53:34 +01:00
asarium 2bddcf8344 Fix Assert in Lua API when passing invalid name to mn.WaypointLists
Since atoi return 0 on error the code tries to access the waypoint list
with index -1 which causes an assert in the lookup code. This fixes that
by using the error detection capabilities of strtol.
2018-03-16 23:53:19 +01:00
553 changed files with 15401 additions and 6403 deletions

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
---
Checks: "-*,\
modernize-*,\
-modernize-raw-string-literal,\
-modernize-use-using,\
performance-*,\
-performance-type-promotion-in-math-fn,\
misc-*,\
-misc-macro-parentheses,\
-misc-misplaced-widening-cast,\
-misc-static-assert,\
"
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
+14 -8
View File
@@ -3,7 +3,7 @@ sudo: required
dist: trusty
cache:
directories:
- $HOME/cmake
- $HOME/cmake-3.8
- $HOME/.ccache
addons:
apt:
@@ -86,16 +86,21 @@ matrix:
- g++-7
- *global_deps
- os: linux
env: CONFIGURATION="Debug" CC=clang-3.6 CXX=clang++-3.6
env: CONFIGURATION="Debug" CC=clang-4.0 CXX=clang++-4.0 CMAKE_OPTIONS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
addons:
apt:
sources:
- llvm-toolchain-precise
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- sourceline: 'ppa:beineri/opt-qt571-trusty'
packages:
- *global_deps
- clang-3.6
- clang-4.0
- clang-tidy-4.0
- libc++-dev
script:
- ./ci/travis/script.sh
- ./ci/travis/clang_tidy.sh
- os: osx
env: CONFIGURATION="Debug"
@@ -120,15 +125,16 @@ matrix:
- g++-7
- *global_deps
- os: linux
env: CONFIGURATION="Release" CC=clang-3.6 CXX=clang++-3.6
env: CONFIGURATION="Release" CC=clang-4.0 CXX=clang++-4.0
addons:
apt:
sources:
- llvm-toolchain-precise
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- sourceline: 'ppa:beineri/opt-qt571-trusty'
packages:
- *global_deps
- clang-3.6
- clang-4.0
- libc++-dev
- os: osx
env: CONFIGURATION="Release"
@@ -143,7 +149,7 @@ before_install:
- "./ci/travis/before_install.sh"
install:
- "./ci/travis/install.sh"
- export PATH=$HOME/cmake/bin:$PATH
- export PATH=$HOME/cmake-3.6/bin:$PATH
before_script:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then QT_ENV_SCRIPT=$(find /opt -name 'qt*-env.sh'); source $QT_ENV_SCRIPT; fi
- "./ci/travis/before_script.sh"
+6
View File
@@ -116,6 +116,8 @@ SET(FSO_RUN_ARGUMENTS "" CACHE STRING "Additional arguments passed to a generate
option(FSO_INSTALL_DEBUG_FILES "Install some debug files (currently only PDB files on windows)" OFF)
option(ENABLE_COTIRE "Enable cotire for faster compilation. Enabled by default." ON)
MARK_AS_ADVANCED(FORCE FSO_CMAKE_DEBUG)
MARK_AS_ADVANCED(FORCE FSO_BUILD_INCLUDED_LIBS)
MARK_AS_ADVANCED(FORCE FSO_USE_OPENALSOFT)
@@ -123,6 +125,7 @@ MARK_AS_ADVANCED(FORCE FSO_USE_LUAJIT)
MARK_AS_ADVANCED(FORCE FSO_DEVELOPMENT_MODE)
MARK_AS_ADVANCED(FORCE FSO_FATAL_WARNINGS)
mark_as_advanced(FORCE FSO_INSTALL_DEBUG_FILES)
mark_as_advanced(FORCE ENABLE_COTIRE)
# Include cotire file from https://github.com/sakra/cotire/
include(cotire)
@@ -142,6 +145,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)
@@ -186,6 +191,7 @@ include(doxygen)
IF (WIN32)
message(STATUS "Using text to speech: ${FSO_USE_SPEECH}")
message(STATUS "Using voice recogition: ${FSO_USE_VOICEREC}")
message(STATUS "Building FRED2: ${FSO_BUILD_FRED2}")
elseif(UNIX)
message(STATUS "Building AppImage: ${FSO_BUILD_APPIMAGE}")
ENDIF()
+5 -4
View File
@@ -1,4 +1,5 @@
version: 1.0.0.{build}
image: Visual Studio 2015
configuration:
- Debug
- Release
@@ -6,13 +7,13 @@ clone_depth: 10
environment:
matrix:
- BuildID: 0
CMAKE_GENERATOR: Visual Studio 12 2013
PlatformToolset: v120_xp
QT_DIR: C:\Qt\5.7\msvc2013
CMAKE_GENERATOR: Visual Studio 14 2015
PlatformToolset: v140_xp
QT_DIR: C:\Qt\5.9.5\msvc2015
- BuildID: 1
CMAKE_GENERATOR: Visual Studio 14 2015 Win64
PlatformToolset: v140_xp
QT_DIR: C:\Qt\5.7\msvc2015_64
QT_DIR: C:\Qt\5.9.5\msvc2015_64
before_build:
- git submodule update --init --recursive
build_script:
+7 -7
View File
@@ -14,7 +14,7 @@ $NightlyConfigurations = @(
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.7\msvc2015_64";
QtDir="C:\Qt\5.9.5\msvc2015_64";
SourcePackage=$false;
},
[BuildConfig]@{
@@ -22,7 +22,7 @@ $NightlyConfigurations = @(
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.7\msvc2015";
QtDir="C:\Qt\5.9.5\msvc2015";
SourcePackage=$false;
}
)
@@ -32,7 +32,7 @@ $ReleaseConfigurations = @(
PackageType="Win32";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.7\msvc2015";
QtDir="C:\Qt\5.9.5\msvc2015";
SourcePackage=$true;
}
[BuildConfig]@{
@@ -40,7 +40,7 @@ $ReleaseConfigurations = @(
PackageType="Win32-AVX";
Toolset="v140_xp";
SimdType="AVX";
QtDir="C:\Qt\5.7\msvc2015";
QtDir="C:\Qt\5.9.5\msvc2015";
SourcePackage=$false;
}
[BuildConfig]@{
@@ -48,7 +48,7 @@ $ReleaseConfigurations = @(
PackageType="Win64";
Toolset="v140_xp";
SimdType="SSE2";
QtDir="C:\Qt\5.7\msvc2015_64";
QtDir="C:\Qt\5.9.5\msvc2015_64";
SourcePackage=$false;
}
[BuildConfig]@{
@@ -56,7 +56,7 @@ $ReleaseConfigurations = @(
PackageType="Win64-AVX";
Toolset="v140_xp";
SimdType="AVX";
QtDir="C:\Qt\5.7\msvc2015_64";
QtDir="C:\Qt\5.9.5\msvc2015_64";
SourcePackage=$false;
}
)
@@ -148,7 +148,7 @@ if ($DeployBuild) {
Push-AppveyorArtifact "$($PackageName)-builds-$($buildConfig.PackageType).zip"
} else {
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="ON" -DFSO_BUILD_TESTS="ON" -DMSVC_SIMD_INSTRUCTIONS=SSE2 `
-DFSO_BUILD_QTFRED=ON -DQT5_INSTALL_ROOT="$env:QT_DIR" -DFSO_BUILD_FRED2="OFF" `
-DFSO_BUILD_QTFRED=ON -DQT5_INSTALL_ROOT="$env:QT_DIR" -DFSO_BUILD_FRED2="ON" `
-G "$Env:CMAKE_GENERATOR" -T "$Env:PlatformToolset" ..
cmake --build . --config "$Env:CONFIGURATION" -- /verbosity:minimal
+2 -2
View File
@@ -20,7 +20,7 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
export CXXFLAGS
export CFLAGS
CMAKE="cmake -G Ninja -DFSO_FATAL_WARNINGS=ON"
CMAKE="cmake -G Ninja -DFSO_FATAL_WARNINGS=ON $CMAKE_OPTIONS"
if [ "$BUILD_DEPLOYMENT" = true ]; then
for config in $BUILD_CONFIGS
do
@@ -38,6 +38,6 @@ 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
fi
+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
+5 -7
View File
@@ -4,16 +4,14 @@ 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
+1 -1
View File
@@ -5,7 +5,7 @@ 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
+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()
+3
View File
@@ -41,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}")
+3
View File
@@ -25,4 +25,7 @@
#cmakedefine01 HAVE_CHAR32_T
#cmakedefine01 HAVE_UNICODE_CHAR_LITERAL
#cmakedefine01 HAVE_SNPRINTF
#cmakedefine01 HAVE__SNPRINTF
#endif // __PLATFORM_CHECKS_H__
+1 -3
View File
@@ -73,14 +73,12 @@ 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")
+3 -4
View File
@@ -85,9 +85,7 @@ 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")
set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-empty-body -Wno-clobbered")
set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-array-bounds -Wno-empty-body -Wno-clobbered -Wno-unused-parameter")
set(COMPILER_FLAGS_DEBUG "-O0 -g -Wshadow")
@@ -105,6 +103,7 @@ set(CMAKE_EXE_LINKER_FLAGS "")
IF (MINGW)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++ -Wl,--enable-auto-import")
target_compile_definitions(compiler INTERFACE __USE_MINGW_ANSI_STDIO=1)
ENDIF(MINGW)
if (SANITIZE_FLAGS)
@@ -131,4 +130,4 @@ if (FSO_FATAL_WARNINGS)
endif()
# Always define this to make sure that the fixed width format macros are available
target_compile_definitions(compiler INTERFACE __STDC_FORMAT_MACROS)
target_compile_definitions(compiler INTERFACE __STDC_FORMAT_MACROS=1)
+6 -4
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)
@@ -141,10 +141,12 @@ macro(set_if_not_defined VAR VALUE)
endmacro(set_if_not_defined)
macro(configure_cotire target)
# Disable unity build as it doesn't work well for us
set_target_properties(${target} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
if(ENABLE_COTIRE)
# Disable unity build as it doesn't work well for us
set_target_properties(${target} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
cotire(${target})
cotire(${target})
endif()
endmacro(configure_cotire)
macro(add_target_copy_files)
+17 -1
View File
@@ -37,6 +37,8 @@ TARGET_LINK_LIBRARIES(code PUBLIC compiler)
target_link_libraries(code PUBLIC md5)
enable_clang_tidy(code)
IF (FSO_USE_SPEECH)
find_package(Speech REQUIRED)
target_link_libraries(code PUBLIC speech)
@@ -55,7 +57,21 @@ IF(FSO_BUILD_TOOLS)
ADD_SUBDIRECTORY(cfileextractor)
ENDIF(FSO_BUILD_TOOLS)
set_target_properties(code PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "prefix_header.h")
if (ENABLE_COTIRE)
set_target_properties(code PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h")
else()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-include${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:/FI ${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-include${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
target_compile_options(code PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-include${CMAKE_CURRENT_SOURCE_DIR}/prefix_header.h>")
ELSE()
MESSAGE("Unknown compiler for global includes. This will probably break the build.")
ENDIF()
endif()
include(util)
configure_cotire(code)
+4 -4
View File
@@ -714,7 +714,7 @@ extern void maybe_cheat_fire_synaptic(object *objp, ai_info *aip);
// 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)
void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy, vec3d * /*firing_pos*/, vec3d * /*enemy_pos*/, vec3d * /*enemy_vel*/)
{
ai_info *aip;
ship_weapon *swp;
@@ -1153,7 +1153,7 @@ void ai_big_chase()
}
}
void ai_big_ship(object *objp)
void ai_big_ship(object * /*objp*/)
{
// do nothing
}
@@ -1228,7 +1228,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)
int ai_big_strafe_maybe_retreat(float /*dist*/, vec3d *target_pos)
{
ai_info *aip;
aip = &Ai_info[Ships[Pl_objp->instance].ai_index];
@@ -1704,7 +1704,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(object *pl_objp, int weapon_objnum, int /*consider_target_only*/)
{
ai_info *aip;
ship_info *sip;
+20 -20
View File
@@ -68,7 +68,7 @@
#include "weapon/swarm.h"
#include "weapon/weapon.h"
#include <map>
#include <limits.h>
#include <climits>
#ifdef _MSC_VER
@@ -1132,7 +1132,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 /*frametime*/, 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;
@@ -3453,7 +3453,7 @@ float compute_time_to_enemy(float dist_to_enemy, object *pobjp)
// 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)
void fds_aux(float *dot, float *tts, vec3d *pos, float /*dtime*/, object *objp)
{
vec3d v2s;
@@ -5234,7 +5234,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)
int ai_select_primary_weapon_OLD(object *objp, object * /*other_objp*/, Weapon::Info_Flags flags)
{
ship *shipp = &Ships[objp->instance];
ship_weapon *swp = &shipp->weapons;
@@ -6052,7 +6052,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, int /*priority1*/, int /*priority2*/)
{
ship_weapon *swp;
ship *shipp;
@@ -6546,7 +6546,7 @@ void ai_chase_ct()
/**
* ATTACK submode handler for chase mode.
*/
void ai_chase_eb(ai_info *aip, ship_info *sip, vec3d *predicted_enemy_pos, float dist_to_enemy)
void ai_chase_eb(ai_info *aip, ship_info *sip, vec3d *predicted_enemy_pos, float /*dist_to_enemy*/)
{
vec3d _pep;
float dot_to_enemy, dot_from_enemy;
@@ -6755,7 +6755,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)
void get_behind_ship(ai_info *aip, ship_info *sip, float /*dist_to_enemy*/)
{
vec3d new_pos;
float dot;
@@ -10839,7 +10839,7 @@ void ai_dock()
if (aip->submode == AIS_DOCK_3) {
// Play a ship docking attach sound
snd_play_3d( gamesnd_get_game_sound(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);
@@ -10966,7 +10966,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( gamesnd_get_game_sound(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;
@@ -10986,7 +10986,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( gamesnd_get_game_sound(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);
}
@@ -11385,7 +11385,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)
float gwlr_object_1(object *objp, ai_info * /*aip*/)
{
float max_radius;
object *o;
@@ -12191,7 +12191,7 @@ void ai_maybe_launch_cmeasure(object *objp, ai_info *aip)
}
// --------------------------------------------------------------------------
void ai_preprocess_ignore_objnum(object *objp, ai_info *aip)
void ai_preprocess_ignore_objnum(object * /*objp*/, ai_info *aip)
{
if (aip->ai_flags[AI::AI_Flags::Temporary_ignore])
{
@@ -13024,7 +13024,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 {
@@ -13441,7 +13441,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)
int ai_find_shockwave_weapon(object *objp, ai_info * /*aip*/)
{
missile_obj *mo;
float nearest_dist = 999999.9f;
@@ -13507,7 +13507,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)
int ai_find_shockwave_ship(object *objp, ai_info * /*aip*/)
{
ship_obj *so;
float nearest_dist = 999999.9f;
@@ -14158,7 +14158,7 @@ void ai_frame(int objnum)
}
}
void ai_control_info_check( object *obj, ai_info *aip )
void ai_control_info_check( object * /*obj*/, ai_info *aip )
{
if(aip->ai_override_flags.none_set())
return;
@@ -14797,7 +14797,7 @@ int firing_aspect_seeking_bomb(object *objp)
// *objp collided with big ship *big_objp at global point *collide_pos
// 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 * /*collide_pos*/, vec3d *collision_normal)
{
ai_info *aip;
@@ -14888,7 +14888,7 @@ 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.
*/
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 *hitpos, int /*shield_quadrant*/, vec3d *hit_normal)
{
int hitter_objnum = -2;
object *objp_hitter = NULL;
@@ -15190,7 +15190,7 @@ void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_
// 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, Ship::Exit_Flags /*method*/)
{
int objnum;
object *other_objp;
@@ -15510,7 +15510,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)
void cheat_fire_synaptic(object *objp, ship *shipp, ai_info * /*aip*/)
{
ship_weapon *swp;
swp = &shipp->weapons;
+3 -3
View File
@@ -414,7 +414,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 +426,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;
@@ -1263,7 +1263,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;
+4 -4
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)
@@ -2048,7 +2048,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
}
}
if ( wip->launch_snd != -1 ) {
if ( wip->launch_snd.isValid() ) {
// Don't play turret firing sound if turret sits on player ship... it gets annoying.
if ( parent_objnum != OBJ_INDEX(Player_obj) || (turret->flags[Ship::Subsystem_Flags::Play_sound_for_player]) ) {
snd_play_3d( gamesnd_get_game_sound(wip->launch_snd), turret_pos, &View_position );
@@ -2135,7 +2135,7 @@ void turret_swarm_fire_from_turret(turret_swarm_info *tsi)
}
// maybe sound
if ( Weapon_info[tsi->weapon_class].launch_snd != -1 ) {
if ( Weapon_info[tsi->weapon_class].launch_snd.isValid() ) {
// Don't play turret firing sound if turret sits on player ship... it gets annoying.
if ( tsi->parent_objnum != OBJ_INDEX(Player_obj) ) {
snd_play_3d( gamesnd_get_game_sound(Weapon_info[tsi->weapon_class].launch_snd), &turret_pos, &View_position );
+2 -2
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;
+39 -101
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;
}
@@ -1207,7 +1193,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 +1215,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 +1244,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;
@@ -1290,23 +1276,23 @@ float asteroid_create_explosion(object *objp)
/**
* Play sound when asteroid explodes
*/
void asteriod_explode_sound(object *objp, int type, int play_loud)
static void asteroid_explode_sound(object *objp, int type, int play_loud)
{
int sound_index = -1;
gamesnd_id sound_index;
float range_factor = 1.0f; // how many times sound should traver farther than normal
if (type % NUM_DEBRIS_SIZES <= 1)
{
sound_index = SND_ASTEROID_EXPLODE_SMALL;
sound_index = gamesnd_id(GameSounds::ASTEROID_EXPLODE_SMALL);
range_factor = 5.0;
}
else
{
sound_index = SND_ASTEROID_EXPLODE_LARGE;
sound_index = gamesnd_id(GameSounds::ASTEROID_EXPLODE_LARGE);
range_factor = 10.0f;
}
Assert(sound_index != -1);
Assert(sound_index.isValid());
if ( !play_loud ) {
range_factor = 1.0f;
@@ -1318,9 +1304,9 @@ void asteriod_explode_sound(object *objp, int type, int play_loud)
/**
* Do the area effect for an asteroid exploding
*
* @param asteroid_objp object pointer to asteriod causing explosion
* @param asteroid_objp object pointer to asteroid causing explosion
*/
void asteroid_do_area_effect(object *asteroid_objp)
static void asteroid_do_area_effect(object *asteroid_objp)
{
object *ship_objp;
float damage, blast;
@@ -1382,7 +1368,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.
@@ -1432,35 +1418,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 +1430,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;
@@ -1595,26 +1552,7 @@ void asteroid_maybe_break_up(object *pasteroid_obj)
}
}
int asteroid_get_random_in_cone(vec3d *pos, vec3d *dir, float ang, int danger)
{
int idx;
vec3d asteroid_dir;
// just pick the first asteroid which satisfies our condition
for(idx=0; idx<Num_asteroids; idx++){
vm_vec_sub(&asteroid_dir, &Objects[Asteroids[idx].objnum].pos, pos);
vm_vec_normalize_quick(&asteroid_dir);
// if it satisfies the condition
if(vm_vec_dot(dir, &asteroid_dir) >= ang){
return idx;
}
}
return -1;
}
void asteroid_test_collide(object *pasteroid_obj, object *pship_obj, mc_info *mc, bool lazy = false)
static void asteroid_test_collide(object *pasteroid_obj, object *pship_obj, mc_info *mc, bool lazy = false)
{
float asteroid_ray_dist;
vec3d asteroid_fvec, terminus;
@@ -1656,7 +1594,7 @@ void asteroid_test_collide(object *pasteroid_obj, object *pship_obj, mc_info *mc
*
* @return !0 if the asteroid will collide with the escort
*/
int asteroid_will_collide(object *pasteroid_obj, object *escort_objp)
static int asteroid_will_collide(object *pasteroid_obj, object *escort_objp)
{
mc_info mc;
mc_info_init(&mc);
@@ -1674,7 +1612,7 @@ int asteroid_will_collide(object *pasteroid_obj, object *escort_objp)
* Warn if asteroid on collision path with ship
* @return !0 if we should warn about asteroid hitting ship, otherwise return 0
*/
int asteroid_valid_ship_to_warn_collide(ship *shipp)
static int asteroid_valid_ship_to_warn_collide(ship *shipp)
{
if ( !(Ship_info[shipp->ship_info_index].is_big_or_huge()) ) {
return 0;
@@ -1696,7 +1634,7 @@ int asteroid_valid_ship_to_warn_collide(ship *shipp)
* See if asteroid will collide with a large ship on the escort list in the next
* ASTEROID_MIN_COLLIDE_TIME seconds.
*/
void asteroid_update_collide_flag(object *asteroid_objp)
static void asteroid_update_collide_flag(object *asteroid_objp)
{
int i, num_escorts, escort_objnum, will_collide=0;
ship *escort_shipp;
@@ -1735,7 +1673,7 @@ void asteroid_update_collide_flag(object *asteroid_objp)
/**
* Ensure that the collide objnum for the asteroid is still valid
*/
void asteroid_verify_collide_objnum(asteroid *asp)
static void asteroid_verify_collide_objnum(asteroid *asp)
{
if ( asp->collide_objnum >= 0 ) {
if ( Objects[asp->collide_objnum].signature != asp->collide_objsig ) {
@@ -1815,7 +1753,7 @@ float asteroid_time_to_impact(object *asteroid_objp)
/**
* Read in a single asteroid section from asteroid.tbl
*/
void asteroid_parse_section(asteroid_info *asip)
static void asteroid_parse_section(asteroid_info *asip)
{
required_string("$Name:");
stuff_string(asip->name, F_NAME, NAME_LENGTH);
@@ -1915,7 +1853,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];
@@ -2066,7 +2004,7 @@ void asteroid_parse_tbl()
/**
* Return number of asteroids expected to collide with a ship.
*/
int count_incident_asteroids()
static int count_incident_asteroids()
{
object *asteroid_objp;
int count;
@@ -2090,7 +2028,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);
+2 -2
View File
@@ -1231,7 +1231,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 +1246,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
}
+37 -9
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
@@ -90,17 +100,35 @@ struct bitmap_entry {
#endif
};
extern bitmap_entry* bm_bitmaps;
struct bitmap_slot {
bitmap_entry entry;
gr_bitmap_info* gr_info = nullptr;
};
// image specific lock functions
void bm_lock_ani( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_dds( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_png( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_apng( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_jpg( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_pcx( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_tga( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_user( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_ani( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_dds( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_png( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_apng( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_jpg( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_pcx( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_tga( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
void bm_lock_user( int handle, bitmap_slot *bs, bitmap *bmp, int bpp, ubyte flags );
const size_t BM_BLOCK_SIZE = 4096;
extern SCP_vector<std::array<bitmap_slot, BM_BLOCK_SIZE>> bm_blocks;
bitmap_slot* bm_get_slot(int handle, bool separate_ani_frames = true);
inline bitmap_entry* bm_get_entry(int handle, bool separate_ani_frames = true) {
return &bm_get_slot(handle, separate_ani_frames)->entry;
}
template<typename T>
T* bm_get_gr_info(int handle, bool separate_ani_frames = true) {
return static_cast<T*>(bm_get_slot(handle, separate_ani_frames)->gr_info);
}
#endif // __BM_INTERNAL_H__
+726 -721
View File
File diff suppressed because it is too large. Load diff
+16 -49
View File
@@ -32,23 +32,6 @@
* @{
*/
/**
* @brief How many bitmaps the game can handle by default
*
* @attention MAX_BITMAPS shouldn't need to be bumped again. With the fixed bm_release() and it's proper use even the
* largest missions should stay under this number. With the largest retail missions and wasteful content we should
* still have about 20% of the slots free. If it still goes over then it's something the artists need to fix.
* For instance the Terran Mara fighter, with -spec and -glow and using the Shinepack, needs 117 bitmap slots alone.
* 111 of those is just for the glowmaps. This number can be greatly reduced if the number of ani frames for another
* LOD than LOD0 has fewer or no ani frames. A 37 frame glow ani for LOD2 is little more than a waste of resources.
* Future reports of texture corruption should be initially approached with content as the cause and not code.
* If anything we could/should reduce MAX_BITMAPS in the future. Where it's at now should accomidate even the
* largest mods. -- Taylor
*/
#define DEFAULT_MAX_BITMAPS 4750
extern int MAX_BITMAPS;
// Flag positions for bitmap.flags
// ***** NOTE: bitmap.flags is an 8-bit value, no more BMP_TEX_* flags can be added unless the type is changed!! ******
#define BMP_AABITMAP (1<<0) //!< antialiased bitmap
@@ -115,6 +98,10 @@ struct bitmap
*/
};
// Forward definition for the graphics API
struct bitmap_entry;
struct bitmap_slot;
extern size_t bm_texture_ram; //!< how many bytes of textures are used.
extern int Bm_paging; //!< Bool type that indicates if BMPMAN is currently paging.
@@ -143,22 +130,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)
@@ -412,13 +383,6 @@ void bm_get_filename(int bitmapnum, char *filename);
*/
const char *bm_get_filename(int handle);
/**
* @brief Loads all data for all bitmaps that have been requested to be loaded
*
* @note This function is not defined.
*/
void bm_gfx_load_all();
/**
* @brief Unloads all used bitmaps, should only ever be called by game_shutdown()
*
@@ -437,15 +401,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
*
@@ -741,6 +696,18 @@ int bm_get_array_index(const int handle);
*/
int bmpman_count_bitmaps();
/**
* @brief Counts how many slots are available to the bmpman system
*
* Since the number of slots is dynamic now, this should be used for determining the total amount of available slots at
* the moment.
*
* @warning This is entirely for debugging and logging purposes. It should not be used in actual engine code.
*
* @return The number of available slots
*/
int bmpman_count_available_slots();
/**
* @brief Checks if the given filename is a valid effect or texture file name
*
+3 -3
View File
@@ -245,12 +245,12 @@ 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)
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 +802,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) {
+1 -1
View File
@@ -143,7 +143,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; }
+55 -49
View File
@@ -10,10 +10,10 @@
#define _CFILE_INTERNAL
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cerrno>
#include <sys/stat.h>
#ifdef _WIN32
@@ -48,50 +48,56 @@ char Cfile_user_dir_legacy[CFILE_ROOT_DIRECTORY_LEN] = "";
//
// Please make sure extensions are all lower-case, or we'll break unix compatibility
//
cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
// What type this is Path Extensions Parent type
{ CF_TYPE_INVALID, NULL, NULL, CF_TYPE_INVALID },
// Root must be index 1!!
{ CF_TYPE_ROOT, "", ".mve .ogg", CF_TYPE_ROOT },
{ CF_TYPE_DATA, "data", ".cfg .txt", CF_TYPE_ROOT },
{ CF_TYPE_MAPS, "data" DIR_SEPARATOR_STR "maps", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
{ CF_TYPE_TEXT, "data" DIR_SEPARATOR_STR "text", ".txt .net", CF_TYPE_DATA },
{ CF_TYPE_MODELS, "data" DIR_SEPARATOR_STR "models", ".pof", CF_TYPE_DATA },
{ CF_TYPE_TABLES, "data" DIR_SEPARATOR_STR "tables", ".tbl .tbm", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS, "data" DIR_SEPARATOR_STR "sounds", ".wav .ogg", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS_8B22K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "8b22k", ".wav .ogg", CF_TYPE_SOUNDS },
{ CF_TYPE_SOUNDS_16B11K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "16b11k", ".wav .ogg", CF_TYPE_SOUNDS },
{ CF_TYPE_VOICE, "data" DIR_SEPARATOR_STR "voice", "", CF_TYPE_DATA },
{ CF_TYPE_VOICE_BRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "briefing", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_CMD_BRIEF, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "command_briefings", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_DEBRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "debriefing", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_PERSONAS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "personas", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_SPECIAL, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "special", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_TRAINING, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "training", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_MUSIC, "data" DIR_SEPARATOR_STR "music", ".wav .ogg", CF_TYPE_DATA },
{ CF_TYPE_MOVIES, "data" DIR_SEPARATOR_STR "movies", ".mve .msb .ogg .mp4", CF_TYPE_DATA },
{ CF_TYPE_INTERFACE, "data" DIR_SEPARATOR_STR "interface", ".pcx .ani .dds .tga .eff .png .jpg", CF_TYPE_DATA },
{ CF_TYPE_FONT, "data" DIR_SEPARATOR_STR "fonts", ".vf .ttf", CF_TYPE_DATA },
{ CF_TYPE_EFFECTS, "data" DIR_SEPARATOR_STR "effects", ".ani .eff .pcx .neb .tga .jpg .png .dds .sdr", CF_TYPE_DATA },
{ CF_TYPE_HUD, "data" DIR_SEPARATOR_STR "hud", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
{ CF_TYPE_PLAYERS, "data" DIR_SEPARATOR_STR "players", ".hcf", CF_TYPE_DATA },
{ CF_TYPE_PLAYER_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "images", ".pcx .png .dds", CF_TYPE_PLAYERS },
{ CF_TYPE_SQUAD_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "squads", ".pcx .png .dds", CF_TYPE_PLAYERS },
{ CF_TYPE_SINGLE_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "single", ".pl2 .cs2 .plr .csg .css", CF_TYPE_PLAYERS },
{ CF_TYPE_MULTI_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "multi", ".plr", CF_TYPE_PLAYERS },
{ CF_TYPE_CACHE, "data" DIR_SEPARATOR_STR "cache", ".clr .tmp .bx", CF_TYPE_DATA }, //clr=cached color
{ CF_TYPE_MULTI_CACHE, "data" DIR_SEPARATOR_STR "multidata", ".pcx .png .dds .fs2 .txt", CF_TYPE_DATA },
{ CF_TYPE_MISSIONS, "data" DIR_SEPARATOR_STR "missions", ".fs2 .fc2 .ntl .ssv", CF_TYPE_DATA },
{ CF_TYPE_CONFIG, "data" DIR_SEPARATOR_STR "config", ".cfg .tbl .tbm .xml .csv", CF_TYPE_DATA },
{ CF_TYPE_DEMOS, "data" DIR_SEPARATOR_STR "demos", ".fsd", CF_TYPE_DATA },
{ CF_TYPE_CBANIMS, "data" DIR_SEPARATOR_STR "cbanims", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
{ CF_TYPE_INTEL_ANIMS, "data" DIR_SEPARATOR_STR "intelanims", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
{ CF_TYPE_SCRIPTS, "data" DIR_SEPARATOR_STR "scripts", ".lua .lc", CF_TYPE_DATA },
{ CF_TYPE_FICTION, "data" DIR_SEPARATOR_STR "fiction", ".txt", CF_TYPE_DATA },
{ CF_TYPE_FREDDOCS, "data" DIR_SEPARATOR_STR "freddocs", ".html", CF_TYPE_DATA },
cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
// What type this is Path Extensions Parent
// type
{CF_TYPE_INVALID, NULL, NULL, CF_TYPE_INVALID},
// Root must be index 1!!
{CF_TYPE_ROOT, "", ".mve .ogg", CF_TYPE_ROOT},
{CF_TYPE_DATA, "data", ".cfg .txt", CF_TYPE_ROOT},
{CF_TYPE_MAPS, "data" DIR_SEPARATOR_STR "maps", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA},
{CF_TYPE_TEXT, "data" DIR_SEPARATOR_STR "text", ".txt .net", CF_TYPE_DATA},
{CF_TYPE_MODELS, "data" DIR_SEPARATOR_STR "models", ".pof", CF_TYPE_DATA},
{CF_TYPE_TABLES, "data" DIR_SEPARATOR_STR "tables", ".tbl .tbm", CF_TYPE_DATA},
{CF_TYPE_SOUNDS, "data" DIR_SEPARATOR_STR "sounds", ".wav .ogg", CF_TYPE_DATA},
{CF_TYPE_SOUNDS_8B22K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "8b22k", ".wav .ogg", CF_TYPE_SOUNDS},
{CF_TYPE_SOUNDS_16B11K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "16b11k", ".wav .ogg", CF_TYPE_SOUNDS},
{CF_TYPE_VOICE, "data" DIR_SEPARATOR_STR "voice", "", CF_TYPE_DATA},
{CF_TYPE_VOICE_BRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "briefing", ".wav .ogg",
CF_TYPE_VOICE},
{CF_TYPE_VOICE_CMD_BRIEF, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "command_briefings", ".wav .ogg",
CF_TYPE_VOICE},
{CF_TYPE_VOICE_DEBRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "debriefing", ".wav .ogg",
CF_TYPE_VOICE},
{CF_TYPE_VOICE_PERSONAS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "personas", ".wav .ogg", CF_TYPE_VOICE},
{CF_TYPE_VOICE_SPECIAL, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "special", ".wav .ogg", CF_TYPE_VOICE},
{CF_TYPE_VOICE_TRAINING, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "training", ".wav .ogg", CF_TYPE_VOICE},
{CF_TYPE_MUSIC, "data" DIR_SEPARATOR_STR "music", ".wav .ogg", CF_TYPE_DATA},
{CF_TYPE_MOVIES, "data" DIR_SEPARATOR_STR "movies", ".mve .msb .ogg .mp4 .srt", CF_TYPE_DATA},
{CF_TYPE_INTERFACE, "data" DIR_SEPARATOR_STR "interface", ".pcx .ani .dds .tga .eff .png .jpg", CF_TYPE_DATA},
{CF_TYPE_FONT, "data" DIR_SEPARATOR_STR "fonts", ".vf .ttf", CF_TYPE_DATA},
{CF_TYPE_EFFECTS, "data" DIR_SEPARATOR_STR "effects", ".ani .eff .pcx .neb .tga .jpg .png .dds .sdr", CF_TYPE_DATA},
{CF_TYPE_HUD, "data" DIR_SEPARATOR_STR "hud", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA},
{CF_TYPE_PLAYERS, "data" DIR_SEPARATOR_STR "players", ".hcf", CF_TYPE_DATA},
{CF_TYPE_PLAYER_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "images", ".pcx .png .dds",
CF_TYPE_PLAYERS},
{CF_TYPE_SQUAD_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "squads", ".pcx .png .dds",
CF_TYPE_PLAYERS},
{CF_TYPE_SINGLE_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "single", ".pl2 .cs2 .plr .csg .css",
CF_TYPE_PLAYERS},
{CF_TYPE_MULTI_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "multi", ".plr", CF_TYPE_PLAYERS},
{CF_TYPE_CACHE, "data" DIR_SEPARATOR_STR "cache", ".clr .tmp .bx", CF_TYPE_DATA}, // clr=cached color
{CF_TYPE_MULTI_CACHE, "data" DIR_SEPARATOR_STR "multidata", ".pcx .png .dds .fs2 .txt", CF_TYPE_DATA},
{CF_TYPE_MISSIONS, "data" DIR_SEPARATOR_STR "missions", ".fs2 .fc2 .ntl .ssv", CF_TYPE_DATA},
{CF_TYPE_CONFIG, "data" DIR_SEPARATOR_STR "config", ".cfg .tbl .tbm .xml .csv", CF_TYPE_DATA},
{CF_TYPE_DEMOS, "data" DIR_SEPARATOR_STR "demos", ".fsd", CF_TYPE_DATA},
{CF_TYPE_CBANIMS, "data" DIR_SEPARATOR_STR "cbanims", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA},
{CF_TYPE_INTEL_ANIMS, "data" DIR_SEPARATOR_STR "intelanims", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA},
{CF_TYPE_SCRIPTS, "data" DIR_SEPARATOR_STR "scripts", ".lua .lc", CF_TYPE_DATA},
{CF_TYPE_FICTION, "data" DIR_SEPARATOR_STR "fiction", ".txt", CF_TYPE_DATA},
{CF_TYPE_FREDDOCS, "data" DIR_SEPARATOR_STR "freddocs", ".html", CF_TYPE_DATA},
};
#define CFILE_STACK_MAX 8
int cfile_inited = 0;
@@ -467,7 +473,7 @@ char *cf_add_ext(const char *filename, const char *ext)
size_t elen = strlen(ext);
Assert(flen < MAX_PATH_LEN);
strcpy_s(path, filename);
if ((flen < 4) || stricmp(path + flen - elen, ext)) {
if ((flen < 4) || stricmp(path + flen - elen, ext) != 0) {
Assert(flen + elen < MAX_PATH_LEN);
strcat_s(path, ext);
}
@@ -561,7 +567,7 @@ void cf_attrib(const char *filename, int set, int clear, int dir_type)
fclose(fp);
DWORD z = GetFileAttributes(longname);
SetFileAttributes(longname, z | set & ~clear);
SetFileAttributes(longname, z | (set & ~clear));
}
}
@@ -686,7 +692,7 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
Assert( mode != NULL );
// Can only open read-only binary files in memory mapped mode.
if ( (type & CFILE_MEMORY_MAPPED) && strcmp(mode,"rb") ) {
if ( (type & CFILE_MEMORY_MAPPED) && strcmp(mode,"rb") != 0 ) {
Int3();
return NULL;
}
+8 -11
View File
@@ -13,7 +13,7 @@
#define __CFILE_H__
#include <time.h>
#include <ctime>
#include "globalincs/pstypes.h"
#include <stdexcept>
@@ -198,9 +198,9 @@ int cfwrite_compressed(void *param_buf, int param_elsize, int param_nelem, CFILE
int cfseek(CFILE *fp, int offset, int where);
// Returns current position of file.
int cftell(CFILE *fp);
// cfputc() writes a character to a file
int cftell(CFILE *fp);
// cfputc() writes a character to a file
int cfputc(int c, CFILE *cfile);
// cfputs() writes a string to a file
@@ -365,16 +365,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();
}
@@ -385,7 +382,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)
{
}
+3 -3
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>
+3 -3
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>
+7 -7
View File
@@ -9,10 +9,10 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cerrno>
#include <sstream>
#include <algorithm>
@@ -649,7 +649,7 @@ void cf_search_root_path(int root_index)
struct dirent *dir = nullptr;
while ((dir = readdir (parentDirP)) != nullptr) {
if (stricmp(search_name, dir->d_name)) {
if (stricmp(search_name, dir->d_name) != 0) {
continue;
}
@@ -1359,7 +1359,7 @@ int cf_find_file_location_ext( const char *filename, const int ext_num, const ch
continue;
// ... check that we match the base filename
if ( strnicmp(f->name_ext, filespec, filespec_len) )
if ( strnicmp(f->name_ext, filespec, filespec_len) != 0 )
continue;
// ... make sure that it's one of our supported types
@@ -2294,7 +2294,7 @@ int cf_create_default_path_string(char *path, uint path_max, int pathtype, const
// filename - optional, if set, tacks the filename onto end of path.
// Output: path - Fully qualified pathname.
//Returns 0 if the result would be too long (invalid result)
int cf_create_default_path_string( SCP_string &path, int pathtype, const char *filename, bool localize )
int cf_create_default_path_string( SCP_string &path, int pathtype, const char *filename, bool /*localize*/ )
{
#ifdef SCP_UNIX
if ( filename && strpbrk(filename,"/") ) {
+14 -13
View File
@@ -39,8 +39,8 @@
#include <dirent.h>
#endif
#include <string.h>
#include <stdlib.h>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <jansson.h>
@@ -219,7 +219,6 @@ Flag exe_params[] =
{ "-set_cpu_affinity", "Sets processor affinity to config value", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
{ "-nograb", "Disables mouse grabbing", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nograb", },
{ "-noshadercache", "Disables the shader cache", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noshadercache", },
{ "-no_bindless_tex", "Disable bindless texturing", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_bindless_tex", },
#ifdef WIN32
{ "-fix_registry", "Use a different registry path", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
#endif
@@ -450,7 +449,6 @@ cmdline_parm no_geo_sdr_effects("-no_geo_effects", NULL, AT_NONE);
cmdline_parm set_cpu_affinity("-set_cpu_affinity", NULL, AT_NONE);
cmdline_parm nograb_arg("-nograb", NULL, AT_NONE);
cmdline_parm noshadercache_arg("-noshadercache", NULL, AT_NONE);
cmdline_parm no_bindless_tex_arg("-no_bindless_tex", NULL, AT_NONE);
#ifdef WIN32
cmdline_parm fix_registry("-fix_registry", NULL, AT_NONE);
#endif
@@ -469,7 +467,6 @@ bool Cmdline_no_geo_sdr_effects = false;
bool Cmdline_set_cpu_affinity = false;
bool Cmdline_nograb = false;
bool Cmdline_noshadercache = false;
bool Cmdline_no_bindless_textures = false;
#ifdef WIN32
bool Cmdline_alternate_registry_path = false;
#endif
@@ -821,7 +818,7 @@ void os_validate_parms(int argc, char *argv[])
size_t sp = 0;
for (parmp = GET_FIRST(&Parm_list); parmp !=END_OF_LIST(&Parm_list); parmp = GET_NEXT(parmp) ) {
// don't output deprecated flags
if (stricmp("deprecated", parmp->help)) {
if (stricmp("deprecated", parmp->help) != 0) {
sp = strlen(parmp->name);
if (parmp->arg_type != AT_NONE) {
atp = strlen(cmdline_arg_types[parmp->arg_type]);
@@ -1170,7 +1167,7 @@ bool cmdline_parm::has_param() {
#ifdef SCP_UNIX
// Return a vector with all filesystem names of "parent/dir" relative to parent.
// dir must not contain a slash.
static SCP_vector<SCP_string> unix_get_single_dir_names(SCP_string parent, SCP_string dir)
static SCP_vector<SCP_string> unix_get_single_dir_names(const SCP_string& parent, const SCP_string& dir)
{
SCP_vector<SCP_string> ret;
@@ -1193,7 +1190,7 @@ static SCP_vector<SCP_string> unix_get_single_dir_names(SCP_string parent, SCP_s
// Return a vector with all filesystem names of "parent/dir" relative to parent.
// Recurses to deal with slashes in dir.
static SCP_vector<SCP_string> unix_get_dir_names(SCP_string parent, SCP_string dir)
static SCP_vector<SCP_string> unix_get_dir_names(const SCP_string& parent, const SCP_string& dir)
{
size_t slash = dir.find_first_of("/\\");
@@ -1394,6 +1391,15 @@ static json_t* json_get_v1() {
json_object_set_new(openal_obj, "capture_devices", capture_array);
}
{
auto efx_support_obj = json_object();
for (auto& pair : openal_info.efx_support) {
json_object_set_new(efx_support_obj, pair.first.c_str(), json_boolean(pair.second));
}
json_object_set_new(openal_obj, "efx_support", efx_support_obj);
}
json_object_set_new(root, "openal", openal_obj);
}
@@ -1940,11 +1946,6 @@ bool SetCmdlineParams()
Cmdline_noshadercache = true;
}
if (no_bindless_tex_arg.found())
{
Cmdline_no_bindless_textures = true;
}
if (portable_mode.found())
{
Cmdline_portable_mode = true;
-1
View File
@@ -135,7 +135,6 @@ extern bool Cmdline_no_geo_sdr_effects;
extern bool Cmdline_set_cpu_affinity;
extern bool Cmdline_nograb;
extern bool Cmdline_noshadercache;
extern bool Cmdline_no_bindless_textures;
#ifdef WIN32
extern bool Cmdline_alternate_registry_path;
#endif
+1 -1
View File
@@ -92,7 +92,7 @@ void cmeasure_maybe_alert_success(object *objp)
if ( objp->parent == OBJ_INDEX(Player_obj) ) {
hud_start_text_flash(XSTR("Evaded", 1430), 800);
snd_play(gamesnd_get_game_sound(ship_get_sound(Player_obj, SND_MISSILE_EVADED_POPUP)));
snd_play(gamesnd_get_game_sound(ship_get_sound(Player_obj, GameSounds::MISSILE_EVADED_POPUP)));
} else if ( Objects[objp->parent].flags[Object::Object_Flags::Player_ship] ) {
send_countermeasure_success_packet( objp->parent );
}
+47 -47
View File
@@ -356,7 +356,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 +615,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 +664,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 +715,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 +723,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 +731,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 +755,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 +766,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 +776,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 +787,7 @@ int control_config_clear_other()
}
if (!total) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -808,7 +808,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 +820,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 +850,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 +867,7 @@ int control_config_clear_all()
}
if (!total) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
return -1;
}
@@ -888,7 +888,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 +945,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 +981,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 +1026,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 +1042,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 +1059,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 +1076,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 +1091,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 +1118,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 +1142,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 +1166,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 +1189,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 +1206,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 +1237,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 +1250,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 +1281,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 +1799,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 +1810,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 +1825,7 @@ void control_config_do_frame(float frametime)
}
}
gamesnd_play_iface(SND_SCROLL);
gamesnd_play_iface(InterfaceSounds::SCROLL);
break;
case KEY_RIGHT:
@@ -1837,7 +1837,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 +1873,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()) {
@@ -2379,7 +2379,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;
+5 -5
View File
@@ -7,8 +7,8 @@
*
*/
#include <stdio.h>
#include <stdarg.h>
#include <cstdio>
#include <cstdarg>
#include "cfile/cfile.h"
#include "controlconfig/controlsconfig.h"
@@ -201,7 +201,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 +251,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",
+3 -3
View File
@@ -105,7 +105,7 @@ class Decoder {
* @brief Returns the properties of the video
* @return The properties
*/
virtual MovieProperties getProperties() = 0;
virtual MovieProperties getProperties() const = 0;
/**
* @brief Starts decoding the video
@@ -116,9 +116,9 @@ class Decoder {
* @brief Determines if the video has audio
* @return @c true if audio is included in the video
*/
virtual bool hasAudio() = 0;
virtual bool hasAudio() const = 0;
virtual bool hasSubtitles() = 0;
virtual bool hasSubtitles() const = 0;
/**
* @brief Ends decoding of the video file
+12 -12
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;
+3
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
}
+3 -3
View File
@@ -25,11 +25,11 @@ 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;
};
}
}
+198 -88
View File
@@ -11,6 +11,7 @@
#include "cutscene/ffmpeg/VideoDecoder.h"
#include "cutscene/ffmpeg/SubtitleDecoder.h"
#include "FFMPEGDecoder.h"
#include "localization/localize.h"
using namespace libs::ffmpeg;
@@ -39,6 +40,8 @@ const char* CHECKED_EXTENSIONS[] = {
"mve"
};
const char *CHECKED_SUBT_EXTENSIONS[] = {"srt"};
double getFrameRate(AVStream* stream, AVCodecContext* codecCtx) {
auto fps = av_q2d(av_stream_get_r_frame_rate(stream));
@@ -55,48 +58,48 @@ double getFrameRate(AVStream* stream, AVCodecContext* codecCtx) {
return fps;
}
CodecContextParameters getCodecParameters(AVStream* stream) {
CodecContextParameters getCodecParameters(AVStream *stream) {
CodecContextParameters paras;
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(57, 24, 255)
paras.width = stream->codecpar->width;
paras.height = stream->codecpar->height;
paras.width = stream->codecpar->width;
paras.height = stream->codecpar->height;
paras.pixel_format = (AVPixelFormat)stream->codecpar->format;
paras.channel_layout = stream->codecpar->channel_layout;
paras.sample_rate = stream->codecpar->sample_rate;
paras.audio_format = (AVSampleFormat)stream->codecpar->format;
paras.sample_rate = stream->codecpar->sample_rate;
paras.audio_format = (AVSampleFormat)stream->codecpar->format;
paras.codec_id = stream->codecpar->codec_id;
paras.codec_id = stream->codecpar->codec_id;
#else
paras.width = stream->codec->width;
paras.height = stream->codec->height;
paras.width = stream->codec->width;
paras.height = stream->codec->height;
paras.pixel_format = stream->codec->pix_fmt;
paras.channel_layout = stream->codec->channel_layout;
paras.sample_rate = stream->codec->sample_rate;
paras.audio_format = stream->codec->sample_fmt;
paras.sample_rate = stream->codec->sample_rate;
paras.audio_format = stream->codec->sample_fmt;
paras.codec_id = stream->codec->codec_id;
paras.codec_id = stream->codec->codec_id;
#endif
return paras;
return paras;
}
SCP_string normalizeLanguage(const char* langauge_name) {
if (!stricmp(langauge_name, "eng")) {
return "English";
}
if (!stricmp(langauge_name, "ger")) {
return "German";
}
if (!stricmp(langauge_name, "spa")) {
return "Spanish";
}
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));
// Print to log so that we can find the actual value more easily later
mprintf(("FFmpeg log: Found unknown language value '%s'!\n", langauge_name));
// Default to english for everything else
return "English";
// Default to english for everything else
return "English";
}
}
@@ -143,7 +146,8 @@ 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) {
std::unique_ptr<DecoderStatus> status(new DecoderStatus());
auto ctx = stream->m_ctx->ctx();
@@ -165,7 +169,7 @@ std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream>& st
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) {
} else if (audioStream == AVERROR_DECODER_NOT_FOUND) {
mprintf(("FFmpeg: Codec for audio stream could not be found!\n"));
} else {
mprintf(("FFmpeg: Unknown error while finding audio stream!\n"));
@@ -180,28 +184,50 @@ std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream>& st
status->audioStream = ctx->streams[audioStream];
}
auto& current_language = Lcl_languages[Lcl_current_lang];
for (uint32_t i = 0; i < ctx->nb_streams; ++i) {
auto test_stream = ctx->streams[i];
if (subt) {
auto subtCtx = subt->m_ctx->ctx();
auto subtStream = av_find_best_stream(subtCtx, AVMEDIA_TYPE_SUBTITLE, -1, -1, nullptr, 0);
if (subtStream < 0) {
if (subtStream == AVERROR_STREAM_NOT_FOUND) {
mprintf(("FFmpeg: No subtitle stream found in subtitle file!\n"));
} else if (subtStream == AVERROR_DECODER_NOT_FOUND) {
mprintf(("FFmpeg: Codec for subtitle stream could not be found!\n"));
} else {
mprintf(("FFmpeg: Unknown error while finding subtitle stream!\n"));
}
} else {
status->subtitleStream = subtCtx->streams[subtStream];
status->externalSubtitles = true;
status->subtitleStreamIndex = subtStream;
}
}
if (status->subtitleStream == nullptr) {
// We don't have an external subtitle stream or loading from that file has failed
auto &current_language = Lcl_languages[Lcl_current_lang];
for (uint32_t i = 0; i < ctx->nb_streams; ++i) {
auto test_stream = ctx->streams[i];
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(57, 24, 255)
auto& pars = test_stream->codecpar;
auto &pars = test_stream->codecpar;
if (!(pars->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
continue;
}
if (!(pars->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
continue;
}
#endif
AVDictionaryEntry* tag = nullptr;
if ((tag = av_dict_get(test_stream->metadata, "language", nullptr, 0)) == nullptr) {
continue;
}
AVDictionaryEntry *tag = nullptr;
if ((tag = av_dict_get(test_stream->metadata, "language", nullptr, 0)) == nullptr) {
continue;
}
auto normalized_language = normalizeLanguage(tag->value);
auto normalized_language = normalizeLanguage(tag->value);
if (!stricmp(normalized_language.c_str(), current_language.lang_name)) {
status->subtitleStreamIndex = i;
status->subtitleStream = test_stream;
break;
if (!stricmp(normalized_language.c_str(), current_language.lang_name)) {
status->subtitleStreamIndex = i;
status->subtitleStream = test_stream;
break;
}
}
}
@@ -263,36 +289,37 @@ std::unique_ptr<DecoderStatus> initializeStatus(std::unique_ptr<InputStream>& st
status->audioCodec->name ? status->audioCodec->name : "<Unknown>"));
}
if (status->subtitleStreamIndex >= 0) {
// Not really sure if this makes sense for subtitles but it shouldn't break anything...
status->subtitleCodecPars = getCodecParameters(status->subtitleStream);
if (status->subtitleStream != nullptr) {
// Not really sure if this makes sense for subtitles but it shouldn't break anything...
status->subtitleCodecPars = getCodecParameters(status->subtitleStream);
status->subtitleCodec = avcodec_find_decoder(status->subtitleCodecPars.codec_id);
status->subtitleCodec = avcodec_find_decoder(status->subtitleCodecPars.codec_id);
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(57, 24, 255)
status->subtitleCodecCtx = avcodec_alloc_context3(status->subtitleCodec);
status->subtitleCodecCtx = avcodec_alloc_context3(status->subtitleCodec);
err = avcodec_parameters_to_context(status->subtitleCodecCtx, status->subtitleStream->codecpar);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to copy context parameters! Error: %s\n", errorStr));
return nullptr;
}
err = avcodec_parameters_to_context(status->subtitleCodecCtx, status->subtitleStream->codecpar);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to copy context parameters! Error: %s\n", errorStr));
return nullptr;
}
#else
status->subtitleCodecCtx = status->subtitleStream->codec;
status->subtitleCodecCtx = status->subtitleStream->codec;
#endif
err = avcodec_open2(status->subtitleCodecCtx, status->subtitleCodec, nullptr);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to open subtitle codec! Error: %s\n", errorStr));
}
err = avcodec_open2(status->subtitleCodecCtx, status->subtitleCodec, nullptr);
if (err < 0) {
char errorStr[512];
av_strerror(err, errorStr, sizeof(errorStr));
mprintf(("FFMPEG: Failed to open subtitle codec! Error: %s\n", errorStr));
}
mprintf(("FFmpeg: Using subtitle codec %s (%s).\n", status->subtitleCodec->long_name ? status->subtitleCodec->long_name : "<Unknown>",
status->subtitleCodec->name ? status->subtitleCodec->name : "<Unknown>"));
}
mprintf(("FFmpeg: Using subtitle codec %s (%s).\n",
status->subtitleCodec->long_name ? status->subtitleCodec->long_name : "<Unknown>",
status->subtitleCodec->name ? status->subtitleCodec->name : "<Unknown>"));
}
return status;
}
@@ -312,6 +339,27 @@ 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) {
@@ -331,8 +379,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);
if (!status) {
return false;
}
@@ -342,11 +392,12 @@ 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);
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);
@@ -360,14 +411,22 @@ void FFMPEGDecoder::startDecoding() {
std::unique_ptr<VideoDecoder> videoDecoder(new VideoDecoder(m_status.get()));
std::unique_ptr<AudioDecoder> audioDecoder;
std::unique_ptr<SubtitleDecoder> subtitleDecoder;
std::unique_ptr<SubtitleDecoder> subtitleDecoder;
if (hasAudio()) {
audioDecoder.reset(new AudioDecoder(m_status.get()));
}
if (hasSubtitles()) {
subtitleDecoder.reset(new SubtitleDecoder(m_status.get()));
}
if (hasSubtitles()) {
subtitleDecoder.reset(new SubtitleDecoder(m_status.get()));
}
std::unique_ptr<std::thread> subtitle_thread;
if (hasExternalSubtitle()) {
// Start a new thread for the subtitles since otherwise we would need to make sure that neither of the input
// streames starves while the other waits for more space in the queues
subtitle_thread.reset(
new std::thread([this, &subtitleDecoder]() { runSubtitleDecoder(subtitleDecoder.get()); }));
}
auto ctx = m_input->m_ctx->ctx();
AVPacket packet;
@@ -375,13 +434,13 @@ void FFMPEGDecoder::startDecoding() {
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];
@@ -408,13 +467,13 @@ void FFMPEGDecoder::startDecoding() {
pushAudioData(std::move(ptr));
}
} else if (subtitleDecoder && packet.stream_index == m_status->subtitleStreamIndex) {
subtitleDecoder->decodePacket(&packet);
subtitleDecoder->decodePacket(&packet);
SubtitleFramePtr ptr;
while((ptr = subtitleDecoder->getFrame()) != nullptr) {
pushSubtitleData(std::move(ptr));
}
}
SubtitleFramePtr ptr;
while ((ptr = subtitleDecoder->getFrame()) != nullptr) {
pushSubtitleData(std::move(ptr));
}
}
}
if (isDecoding()) {
@@ -434,16 +493,18 @@ void FFMPEGDecoder::startDecoding() {
}
}
if (subtitle_thread) {
subtitle_thread->join();
}
stopDecoder();
}
bool FFMPEGDecoder::hasAudio() {
return m_status->audioStreamIndex >= 0;
}
bool FFMPEGDecoder::hasAudio() const { return m_status->audioStreamIndex >= 0; }
bool FFMPEGDecoder::hasSubtitles() {
return m_status->subtitleStreamIndex >= 0;
}
bool FFMPEGDecoder::hasSubtitles() const { return m_status->subtitleStream != nullptr; }
bool FFMPEGDecoder::hasExternalSubtitle() const { return m_status->externalSubtitles; }
void FFMPEGDecoder::close() {
if (m_status) {
@@ -454,6 +515,55 @@ void FFMPEGDecoder::close() {
// 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 (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->subtitleStreamIndex) {
decoder->decodePacket(&packet);
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
decoder->finishDecoding();
SubtitleFramePtr ptr;
while ((ptr = decoder->getFrame()) != nullptr) {
pushSubtitleData(std::move(ptr));
}
}
}
}
}
+16 -8
View File
@@ -8,28 +8,36 @@ struct InputStream;
struct DecoderStatus;
class SubtitleDecoder;
class FFMPEGDecoder: public Decoder {
private:
std::unique_ptr<InputStream> m_input;
std::unique_ptr<InputStream> m_subtitleInput;
std::unique_ptr<DecoderStatus> m_status;
public:
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) override;
MovieProperties getProperties() SCP_OVERRIDE;
MovieProperties getProperties() const override;
void startDecoding() SCP_OVERRIDE;
void startDecoding() override;
bool hasAudio() SCP_OVERRIDE;
bool hasAudio() const override;
bool hasSubtitles() SCP_OVERRIDE;
bool hasSubtitles() const override;
void close() SCP_OVERRIDE;
void close() override;
};
}
}
+18
View File
@@ -31,7 +31,25 @@ void SubtitleDecoder::decodePacket(AVPacket* packet) {
}
}
void SubtitleDecoder::finishDecoding() {
// Handle those decoders that have a delay
AVPacket nullPacket;
memset(&nullPacket, 0, sizeof(nullPacket));
nullPacket.data = nullptr;
nullPacket.size = 0;
AVSubtitle subtitle;
while (true) {
int finishedFrame = 1;
auto err = avcodec_decode_subtitle2(m_status->subtitleCodecCtx, &subtitle, &finishedFrame, &nullPacket);
if (err < 0 || !finishedFrame) {
break;
}
pushSubtitleFrame(&nullPacket, &subtitle);
avsubtitle_free(&subtitle);
}
}
void SubtitleDecoder::pushSubtitleFrame(AVPacket* packet, AVSubtitle* subtitle) {
if (subtitle->format != 1) {
+3 -3
View File
@@ -10,11 +10,11 @@ class SubtitleDecoder: public FFMPEGStreamDecoder<SubtitleFrame> {
public:
explicit SubtitleDecoder(DecoderStatus* status);
virtual ~SubtitleDecoder();
~SubtitleDecoder() override;
virtual void decodePacket(AVPacket* packet) SCP_OVERRIDE;
void decodePacket(AVPacket* packet) override;
virtual void finishDecoding() SCP_OVERRIDE;
void finishDecoding() override;
void pushSubtitleFrame(AVPacket* subtitle, AVSubtitle* pSubtitle);
};
+2 -2
View File
@@ -22,14 +22,14 @@ class FFMPEGVideoFrame: public VideoFrame {
FFMPEGVideoFrame() : frame(nullptr) {
}
virtual ~FFMPEGVideoFrame() {
~FFMPEGVideoFrame() override {
if (frame != nullptr) {
av_freep(&frame->data[0]);
av_frame_free(&frame);
}
}
virtual DataPointers getDataPointers() {
DataPointers getDataPointers() override {
DataPointers ptrs;
ptrs.y = frame->data[0];
ptrs.u = frame->data[1];
+3 -3
View File
@@ -15,11 +15,11 @@ class VideoDecoder: public FFMPEGStreamDecoder<VideoFrame> {
public:
explicit VideoDecoder(DecoderStatus* status);
virtual ~VideoDecoder();
~VideoDecoder() override;
virtual void decodePacket(AVPacket* packet) SCP_OVERRIDE;
void decodePacket(AVPacket* packet) override;
virtual void finishDecoding() SCP_OVERRIDE;
void finishDecoding() override;
};
}
}
+2
View File
@@ -33,6 +33,8 @@ struct DecoderStatus {
AVCodec* audioCodec = nullptr;
AVCodecContext* audioCodecCtx = nullptr;
// Subtitles are a bit different since they max come from a different file
bool externalSubtitles = false;
int subtitleStreamIndex = -1;
AVStream* subtitleStream = nullptr;
CodecContextParameters subtitleCodecPars;
+8 -8
View File
@@ -74,7 +74,7 @@ static void debris_start_death_roll(object *debris_obj, debris *debris_p)
// only play debris destroy sound if hull piece and it has been around for at least 2 seconds
if ( Missiontime > debris_p->time_started + 2*F1_0 ) {
snd_play_3d( gamesnd_get_game_sound(SND_MISSILE_IMPACT1), &debris_obj->pos, &View_position, debris_obj->radius );
snd_play_3d( gamesnd_get_game_sound(gamesnd_id(GameSounds::MISSILE_IMPACT1)), &debris_obj->pos, &View_position, debris_obj->radius );
}
}
@@ -238,7 +238,7 @@ void debris_process_post(object * obj, float frame_time)
radar_plot_object( obj );
if ( timestamp_elapsed(db->sound_delay) ) {
obj_snd_assign(objnum, SND_DEBRIS, &vmd_zero_vector, 0);
obj_snd_assign(objnum, GameSounds::DEBRIS, &vmd_zero_vector, 0);
db->sound_delay = 0;
}
} else {
@@ -324,19 +324,19 @@ void debris_process_post(object * obj, float frame_time)
//Play a sound effect
if ( lifetime > 750 ) {
// 1.00 second effect
snd_play_3d( gamesnd_get_game_sound(SND_DEBRIS_ARC_05), &snd_pos, &View_position, obj->radius );
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_05), &snd_pos, &View_position, obj->radius );
} else if ( lifetime > 500 ) {
// 0.75 second effect
snd_play_3d( gamesnd_get_game_sound(SND_DEBRIS_ARC_04), &snd_pos, &View_position, obj->radius );
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_04), &snd_pos, &View_position, obj->radius );
} else if ( lifetime > 250 ) {
// 0.50 second effect
snd_play_3d( gamesnd_get_game_sound(SND_DEBRIS_ARC_03), &snd_pos, &View_position, obj->radius );
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_03), &snd_pos, &View_position, obj->radius );
} else if ( lifetime > 100 ) {
// 0.25 second effect
snd_play_3d( gamesnd_get_game_sound(SND_DEBRIS_ARC_02), &snd_pos, &View_position, obj->radius );
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_02), &snd_pos, &View_position, obj->radius );
} else {
// 0.10 second effect
snd_play_3d( gamesnd_get_game_sound(SND_DEBRIS_ARC_01), &snd_pos, &View_position, obj->radius );
snd_play_3d( gamesnd_get_game_sound(GameSounds::DEBRIS_ARC_01), &snd_pos, &View_position, obj->radius );
}
}
}
@@ -693,7 +693,7 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
* Alas, poor debris_obj got whacked. Fortunately, we know who did it, where and how hard, so we
* can do something about it.
*/
void debris_hit(object *debris_obj, object *other_obj, vec3d *hitpos, float damage)
void debris_hit(object *debris_obj, object * /*other_obj*/, vec3d *hitpos, float damage)
{
debris *debris_p = &Debris[debris_obj->instance];
+2 -2
View File
@@ -162,7 +162,7 @@ void dc_do_command(SCP_string *cmd_str)
try {
dc_commands[i]->func(); // Run the command!
} catch (errParseString err) {
} catch (const errParseString& err) {
dc_printf("Require string(s) not found: \n");
for (uint j = 0; j < err.expected_tokens.size(); ++j) {
dc_printf("%i: %s\n", j, err.expected_tokens[j].c_str());
@@ -170,7 +170,7 @@ void dc_do_command(SCP_string *cmd_str)
dc_printf("Found '%s' instead\n", err.found_token.c_str());
} catch (errParse err) {
} catch (const errParse& err) {
dc_printf("Invalid argument. Expected %s, found '%s'\n", token_str[err.expected_type], err.found_token.c_str());
}
+1 -1
View File
@@ -20,7 +20,7 @@
#include <cmath>
#include <cstdarg>
#include <cstring>
#include <limits.h>
#include <climits>
// ========================= LOCALS =========================
+2 -2
View File
@@ -48,10 +48,10 @@ class DecalDefinition {
DecalDefinition& operator=(const DecalDefinition&) = delete;
// Move constructor and operator
DecalDefinition(DecalDefinition&& other) {
DecalDefinition(DecalDefinition&& other) SCP_NOEXCEPT {
*this = std::move(other); // Use operator implementation
}
DecalDefinition& operator=(DecalDefinition&& other) {
DecalDefinition& operator=(DecalDefinition&& other) SCP_NOEXCEPT {
std::swap(_name, other._name);
std::swap(_diffuseFilename, other._diffuseFilename);
+31 -107
View File
@@ -1,8 +1,4 @@
#ifdef FEATURE_BINDLESS_TEXTURES
#extension GL_ARB_bindless_texture : require
#endif
#include "shadows.sdr"
#include "lighting.sdr"
#include "gamma.sdr"
@@ -23,96 +19,6 @@ struct model_light {
vec3 direction;
};
#ifdef FEATURE_BINDLESS_TEXTURES
layout (std140) uniform modelData {
mat4 modelViewMatrix;
mat4 modelMatrix;
mat4 viewMatrix;
mat4 projMatrix;
mat4 textureMatrix;
mat4 shadow_mv_matrix;
mat4 shadow_proj_matrix[4];
mat4 envMatrix;
vec4 color;
model_light lights[MAX_LIGHTS];
float extrudeWidth;
float fogStart;
float fogScale;
int buffer_matrix_offset;
vec4 clip_equation;
float thruster_scale;
bool use_clip_plane;
int n_lights;
float defaultGloss;
vec3 ambientFactor;
int desaturate;
vec3 diffuseFactor;
int blend_alpha;
vec3 emissionFactor;
bool overrideDiffuse;
vec3 diffuseClr;
bool overrideGlow;
vec3 glowClr;
bool overrideSpec;
vec3 specClr;
bool alphaGloss;
bool gammaSpec;
bool envGloss;
bool alpha_spec;
int effect_num;
vec4 fogColor;
vec3 base_color;
float anim_timer;
vec3 stripe_color;
float vpwidth;
float vpheight;
bool team_glow_enabled;
float znear;
float zfar;
float veryneardist;
float neardist;
float middist;
float fardist;
vec2 normalAlphaMinMax;
int sBasemapIndex;
int sGlowmapIndex;
int sSpecmapIndex;
int sNormalmapIndex;
int sAmbientmapIndex;
int sMiscmapIndex;
sampler2DArray sBasemap;
sampler2DArray sGlowmap;
sampler2DArray sSpecmap;
samplerCube sEnvmap;
sampler2DArray sNormalmap;
sampler2DArray sAmbientmap;
sampler2DArray sMiscmap;
sampler2DArray sHeightmap;
};
#else
layout (std140) uniform modelData {
mat4 modelViewMatrix;
mat4 modelMatrix;
@@ -189,17 +95,6 @@ layout (std140) uniform modelData {
int sAmbientmapIndex;
int sMiscmapIndex;
};
uniform sampler2DArray sBasemap;
uniform sampler2DArray sGlowmap;
uniform sampler2DArray sSpecmap;
uniform samplerCube sEnvmap;
uniform sampler2DArray sNormalmap;
uniform sampler2DArray sAmbientmap;
uniform sampler2DArray sMiscmap;
#endif
uniform sampler2D sFramebuffer;
uniform sampler2DArray shadow_map;
in VertexOutput {
#ifdef FLAG_ENV_MAP
@@ -225,9 +120,36 @@ in VertexOutput {
#endif
} vertIn;
#ifdef FLAG_DIFFUSE_MAP
uniform sampler2DArray sBasemap;
#endif
#ifdef FLAG_GLOW_MAP
uniform sampler2DArray sGlowmap;
#endif
#ifdef FLAG_SPEC_MAP
uniform sampler2DArray sSpecmap;
#endif
#ifdef FLAG_ENV_MAP
uniform samplerCube sEnvmap;
#endif
#ifdef FLAG_NORMAL_MAP
uniform sampler2DArray sNormalmap;
#endif
#ifdef FLAG_AMBIENT_MAP
uniform sampler2DArray sAmbientmap;
#endif
#ifdef FLAG_ANIMATED
uniform sampler2D sFramebuffer;
#endif
#ifdef FLAG_TEAMCOLOR
vec2 teamMask = vec2(0.0, 0.0);
#endif
#ifdef FLAG_MISC_MAP
uniform sampler2DArray sMiscmap;
#endif
#ifdef FLAG_SHADOWS
uniform sampler2DArray shadow_map;
#endif
out vec4 fragOut0;
out vec4 fragOut1;
@@ -459,8 +381,10 @@ void main()
#ifdef FLAG_DIFFUSE_MAP
if(blend_alpha == 1) finalFogColor *= baseColor.a;
#endif
baseColor.rgb = mix(baseColor.rgb, finalFogColor, vertIn.fogDist);
emissiveColor.rgb = mix(emissiveColor.rgb, finalFogColor, vertIn.fogDist);
// This code will only be used by the forward renderer so we apply the fog effect to both the emissive and the base
// color.
baseColor.rgb = mix(emissiveColor.rgb + baseColor.rgb, finalFogColor, vertIn.fogDist);
emissiveColor.rgb = vec3(0.0); // Zero the emissive color since it has already been added by the previous line
specColor.rgb *= vertIn.fogDist;
#endif
-95
View File
@@ -1,9 +1,5 @@
#extension GL_ARB_gpu_shader5: enable
#ifdef FEATURE_BINDLESS_TEXTURES
#extension GL_ARB_bindless_texture : require
#endif
layout (triangles) in;
layout (triangle_strip, max_vertices = 3) out;
#ifdef GL_ARB_gpu_shader5
@@ -23,96 +19,6 @@ struct model_light {
vec3 direction;
};
#ifdef FEATURE_BINDLESS_TEXTURES
layout (std140) uniform modelData {
mat4 modelViewMatrix;
mat4 modelMatrix;
mat4 viewMatrix;
mat4 projMatrix;
mat4 textureMatrix;
mat4 shadow_mv_matrix;
mat4 shadow_proj_matrix[4];
mat4 envMatrix;
vec4 color;
model_light lights[MAX_LIGHTS];
float extrudeWidth;
float fogStart;
float fogScale;
int buffer_matrix_offset;
vec4 clip_equation;
float thruster_scale;
bool use_clip_plane;
int n_lights;
float defaultGloss;
vec3 ambientFactor;
int desaturate;
vec3 diffuseFactor;
int blend_alpha;
vec3 emissionFactor;
bool overrideDiffuse;
vec3 diffuseClr;
bool overrideGlow;
vec3 glowClr;
bool overrideSpec;
vec3 specClr;
bool alphaGloss;
bool gammaSpec;
bool envGloss;
bool alpha_spec;
int effect_num;
vec4 fogColor;
vec3 base_color;
float anim_timer;
vec3 stripe_color;
float vpwidth;
float vpheight;
bool team_glow_enabled;
float znear;
float zfar;
float veryneardist;
float neardist;
float middist;
float fardist;
vec2 normalAlphaMinMax;
int sBasemapIndex;
int sGlowmapIndex;
int sSpecmapIndex;
int sNormalmapIndex;
int sAmbientmapIndex;
int sMiscmapIndex;
sampler2DArray sBasemap;
sampler2DArray sGlowmap;
sampler2DArray sSpecmap;
samplerCube sEnvmap;
sampler2DArray sNormalmap;
sampler2DArray sAmbientmap;
sampler2DArray sMiscmap;
sampler2DArray sHeightmap;
};
#else
layout (std140) uniform modelData {
mat4 modelViewMatrix;
mat4 modelMatrix;
@@ -189,7 +95,6 @@ layout (std140) uniform modelData {
int sAmbientmapIndex;
int sMiscmapIndex;
};
#endif
in VertexOutput {
#ifdef FLAG_ENV_MAP
+2 -94
View File
@@ -1,7 +1,4 @@
#extension GL_ARB_gpu_shader5: enable
#ifdef FEATURE_BINDLESS_TEXTURES
#extension GL_ARB_bindless_texture : require
#endif
#include "shadows.sdr"
@@ -25,96 +22,6 @@ struct model_light {
vec3 direction;
};
#ifdef FEATURE_BINDLESS_TEXTURES
layout (std140) uniform modelData {
mat4 modelViewMatrix;
mat4 modelMatrix;
mat4 viewMatrix;
mat4 projMatrix;
mat4 textureMatrix;
mat4 shadow_mv_matrix;
mat4 shadow_proj_matrix[4];
mat4 envMatrix;
vec4 color;
model_light lights[MAX_LIGHTS];
float extrudeWidth;
float fogStart;
float fogScale;
int buffer_matrix_offset;
vec4 clip_equation;
float thruster_scale;
bool use_clip_plane;
int n_lights;
float defaultGloss;
vec3 ambientFactor;
int desaturate;
vec3 diffuseFactor;
int blend_alpha;
vec3 emissionFactor;
bool overrideDiffuse;
vec3 diffuseClr;
bool overrideGlow;
vec3 glowClr;
bool overrideSpec;
vec3 specClr;
bool alphaGloss;
bool gammaSpec;
bool envGloss;
bool alpha_spec;
int effect_num;
vec4 fogColor;
vec3 base_color;
float anim_timer;
vec3 stripe_color;
float vpwidth;
float vpheight;
bool team_glow_enabled;
float znear;
float zfar;
float veryneardist;
float neardist;
float middist;
float fardist;
vec2 normalAlphaMinMax;
int sBasemapIndex;
int sGlowmapIndex;
int sSpecmapIndex;
int sNormalmapIndex;
int sAmbientmapIndex;
int sMiscmapIndex;
sampler2DArray sBasemap;
sampler2DArray sGlowmap;
sampler2DArray sSpecmap;
samplerCube sEnvmap;
sampler2DArray sNormalmap;
sampler2DArray sAmbientmap;
sampler2DArray sMiscmap;
sampler2DArray sHeightmap;
};
#else
layout (std140) uniform modelData {
mat4 modelViewMatrix;
mat4 modelMatrix;
@@ -191,9 +98,10 @@ layout (std140) uniform modelData {
int sAmbientmapIndex;
int sMiscmapIndex;
};
#endif
#ifdef FLAG_TRANSFORM
uniform samplerBuffer transform_tex;
#endif
out VertexOutput {
#ifdef FLAG_ENV_MAP
+1 -1
View File
@@ -16,7 +16,7 @@ struct def_file
const size_t size;
};
#include "def_files/generated_def_files-generic.h"
#include "def_files/generated_def_files-generic.inc"
default_file defaults_get_file(const char *filename)
{
+2 -1
View File
@@ -4,6 +4,7 @@
*/
#include "globalincs/pstypes.h"
#include "def_files/def_files.h"
#include <iterator>
@@ -20,7 +21,7 @@ struct def_file
def_file Default_files[] =
{
#include "def_files/generated_def_files-win32.h"
#include "def_files/generated_def_files-win32.inc"
};
default_file defaults_get_file(const char *filename)
+8 -3
View File
@@ -29,7 +29,7 @@ IF(MSVC)
file(WRITE "${GENERATED_SOURCE_DIR}/code/default_files.rc" "${RES_CONTENT}")
configure_file("def_files/generated_def_files-win32.h.in" "${GENERATED_SOURCE_DIR}/code/def_files/generated_def_files-win32.h")
configure_file("def_files/generated_def_files-win32.inc.in" "${GENERATED_SOURCE_DIR}/code/def_files/generated_def_files-win32.inc")
target_sources(code INTERFACE "${GENERATED_SOURCE_DIR}/code/default_files.rc")
else()
@@ -51,6 +51,10 @@ else()
# Retrieve the path type name from the relative path
GET_FILENAME_COMPONENT(PATH_TYPE "${RELATIVE_FILE_PATH}" DIRECTORY)
file(TO_NATIVE_PATH "${PATH_TYPE}" PATH_TYPE)
if (MINGW)
# There is a bug in CMake where it thinks MinGW uses forward slashes for paths but we need backslashes for Windows builds
string(REPLACE "/" "\\\\" PATH_TYPE "${PATH_TYPE}")
endif()
GET_FILENAME_COMPONENT(FILE_NAME "${RELATIVE_FILE_PATH}" NAME)
string(MAKE_C_IDENTIFIER "${RELATIVE_FILE_PATH}" FIELD_NAME)
@@ -69,14 +73,15 @@ else()
ADD_CUSTOM_COMMAND(
OUTPUT ${ALL_OUTPUTS}
COMMAND embedfile "${INPUT_NAME}" "${OUTPUT}" "${FIELD_NAME}"
DEPENDS "${INPUT_NAME}"
MAIN_DEPENDENCY "${INPUT_NAME}"
DEPENDS embedfile
COMMENT "Generating string file for ${INPUT_NAME}"
)
LIST(APPEND DEF_OUT_FILES ${ALL_OUTPUTS})
ENDFOREACH(file)
configure_file("def_files/generated_def_files-generic.h.in" "${GENERATED_SOURCE_DIR}/code/def_files/generated_def_files-generic.h")
configure_file("def_files/generated_def_files-generic.inc.in" "${GENERATED_SOURCE_DIR}/code/def_files/generated_def_files-generic.inc")
target_sources(code PRIVATE ${DEF_OUT_FILES})
SOURCE_GROUP("Generated Files\\Default Files" FILES ${DEF_OUT_FILES})
+10 -10
View File
@@ -23,7 +23,7 @@
#include "ship/ship.h"
#include "tracing/Monitor.h"
#include <stdlib.h>
#include <cstdlib>
// make use of the LOD checker for tbl/tbm parsing (from weapons.cpp)
@@ -63,7 +63,7 @@ int Warp_ball_bitmap = -1;
*/
void fireball_play_warphole_open_sound(int ship_class, fireball *fb)
{
int sound_index;
gamesnd_id sound_index;
float range_multiplier = 1.0f;
object *fireball_objp;
@@ -73,13 +73,13 @@ void fireball_play_warphole_open_sound(int ship_class, fireball *fb)
}
fireball_objp = &Objects[fb->objnum];
sound_index = SND_WARP_IN;
sound_index = gamesnd_id(GameSounds::WARP_IN);
if(fb->warp_open_sound_index > -1) {
if(fb->warp_open_sound_index.isValid()) {
sound_index = fb->warp_open_sound_index;
} else if ((ship_class >= 0) && (ship_class < static_cast<int>(Ship_info.size()))) {
if ( Ship_info[ship_class].is_huge_ship() ) {
sound_index = SND_CAPITAL_WARP_IN;
sound_index = gamesnd_id(GameSounds::CAPITAL_WARP_IN);
fb->flags |= FBF_WARP_CAPITAL_SIZE;
} else if ( Ship_info[ship_class].is_big_ship() ) {
range_multiplier = 6.0f;
@@ -95,18 +95,18 @@ void fireball_play_warphole_open_sound(int ship_class, fireball *fb)
*/
void fireball_play_warphole_close_sound(fireball *fb)
{
int sound_index;
gamesnd_id sound_index;
object *fireball_objp;
fireball_objp = &Objects[fb->objnum];
sound_index = SND_WARP_OUT;
sound_index = gamesnd_id(GameSounds::WARP_OUT);
if ( fb->warp_close_sound_index > -1 ) {
if ( fb->warp_close_sound_index.isValid() ) {
sound_index = fb->warp_close_sound_index;
} else if ( fb->flags & FBF_WARP_CAPITAL_SIZE ) {
sound_index = SND_CAPITAL_WARP_OUT;
sound_index = gamesnd_id(GameSounds::CAPITAL_WARP_OUT);
} else {
return;
}
@@ -696,7 +696,7 @@ int fireball_get_lod(vec3d *pos, fireball_info *fd, float size)
/**
* Create a fireball, return object index.
*/
int fireball_create( vec3d * pos, int fireball_type, int render_type, int parent_obj, float size, int reverse, vec3d *velocity, float warp_lifetime, int ship_class, matrix *orient_override, int low_res, int extra_flags, int warp_open_sound, int warp_close_sound)
int fireball_create( vec3d * pos, int fireball_type, int render_type, int parent_obj, float size, int reverse, vec3d *velocity, float warp_lifetime, int ship_class, matrix *orient_override, int low_res, int extra_flags, gamesnd_id warp_open_sound, gamesnd_id warp_close_sound)
{
int n, objnum, fb_lod;
object *obj;
+4 -3
View File
@@ -14,6 +14,7 @@
#include "globalincs/pstypes.h"
#include "model/modelrender.h"
#include "gamesnd/gamesnd.h"
class object;
class ship_info;
@@ -71,8 +72,8 @@ typedef struct fireball {
char lod; // current LOD
float time_elapsed; // in seconds
float total_time; // total lifetime of animation in seconds
int warp_open_sound_index; // for warp-effect - Goober5000
int warp_close_sound_index; // for warp-effect - Goober5000
gamesnd_id warp_open_sound_index; // for warp-effect - Goober5000
gamesnd_id warp_close_sound_index; // for warp-effect - Goober5000
} fireball;
// end move
@@ -84,7 +85,7 @@ void fireball_process_post(object * obj, float frame_time);
// reversed is for warp_in/out effects
// Velocity: If not NULL, the fireball will move at a constant velocity.
// warp_lifetime: If warp_lifetime > 0.0f then makes the explosion loop so it lasts this long. Only works for warp effect
int fireball_create(vec3d *pos, int fireball_type, int render_type, int parent_obj, float size, int reversed=0, vec3d *velocity=NULL, float warp_lifetime=0.0f, int ship_class=-1, matrix *orient=NULL, int low_res=0, int extra_flags=0, int warp_open_sound=-1, int warp_close_sound=-1);
int fireball_create(vec3d *pos, int fireball_type, int render_type, int parent_obj, float size, int reversed=0, vec3d *velocity=NULL, float warp_lifetime=0.0f, int ship_class=-1, matrix *orient=NULL, int low_res=0, int extra_flags=0, gamesnd_id warp_open_sound=gamesnd_id(), gamesnd_id warp_close_sound=gamesnd_id());
void fireball_render_plane(int plane);
void fireball_close();
+6 -5
View File
@@ -21,6 +21,7 @@
#include "graphics/2d.h"
#include "graphics/font.h"
#include "io/timer.h"
#include "mission/missionparse.h"
#include "mod_table/mod_table.h"
#include "network/multi.h"
#include "network/multi_log.h"
@@ -38,13 +39,13 @@
#ifndef WIN32
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <unistd.h>
#include <cerrno>
#endif
#include <string>
#include <limits.h>
#include <climits>
#define FS2NETD_DEFAULT_PORT "12009"
@@ -545,7 +546,7 @@ static void fs2netd_handle_ping()
// make sure that we are good to go
if ( !Is_connected ) {
if (!Is_standalone) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
popup(PF_USE_AFFIRMATIVE_ICON | PF_TITLE_BIG | PF_TITLE_RED, 1, POPUP_OK, "ERROR:\nLost connection to the FS2NetD server!");
}
@@ -587,7 +588,7 @@ static void fs2netd_handle_ping()
// make sure that we are good to go
if ( !Is_connected ) {
if (!Is_standalone) {
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
popup(PF_USE_AFFIRMATIVE_ICON | PF_TITLE_BIG | PF_TITLE_RED, 1, POPUP_OK, "ERROR:\nLost connection to the FS2NetD server!");
}
@@ -638,7 +639,7 @@ static void fs2netd_handle_messages()
os_sleep(20);
}
if ( (bytes_read == 0) || (bytes_read < BASE_PACKET_SIZE) ) {
if ( (bytes_read < BASE_PACKET_SIZE) ) {
return;
}
+1 -1
View File
@@ -30,7 +30,7 @@
#include <iostream>
#include <string>
#include <limits.h>
#include <climits>
extern SCP_vector<crc_valid_status> Table_valid_status;
+4 -4
View File
@@ -23,15 +23,15 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdlib.h>
#include <cstdlib>
#include <unistd.h>
#include <cerrno>
#include <sys/ioctl.h>
#include <signal.h>
#include <csignal>
#ifdef SCP_SOLARIS
#include <sys/filio.h>
#endif
#include <ctype.h>
#include <cctype>
#define WSAGetLastError() (errno)
#define RESTART(syscall) \
@@ -94,7 +94,7 @@ int FS2NetD_ConnectToServer(const char *host, const char *port)
mySocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (mySocket == SOCKET_ERROR) {
if (mySocket == (SOCKET)SOCKET_ERROR) {
#ifdef SCP_UNIX
my_error = errno;
ml_printf("FS2NetD ERROR: Couldn't get socket (\"%s\")!", strerror(my_error));
+2 -2
View File
@@ -8,8 +8,8 @@
*/
#include <string.h>
#include <setjmp.h>
#include <cstring>
#include <csetjmp>
#include "controlconfig/controlsconfig.h"
#include "debugconsole/console.h"
+4 -4
View File
@@ -255,7 +255,7 @@ void gameplay_help_goto_prev_screen()
if (Current_help_page < GP_FIRST_SCREEN) {
Current_help_page = Gp_last_screen;
}
gamesnd_play_iface(SND_SWITCH_SCREENS);
gamesnd_play_iface(InterfaceSounds::SWITCH_SCREENS);
}
@@ -266,7 +266,7 @@ void gameplay_help_goto_next_screen()
if (Current_help_page > Gp_last_screen) {
Current_help_page = GP_FIRST_SCREEN;
}
gamesnd_play_iface(SND_SWITCH_SCREENS);
gamesnd_play_iface(InterfaceSounds::SWITCH_SCREENS);
}
// called when the screen is exited
@@ -321,7 +321,7 @@ void gameplay_help_button_pressed(int n)
case CONTINUE_BUTTON:
gameplay_help_leave();
gamesnd_play_iface(SND_COMMIT_PRESSED);
gamesnd_play_iface(InterfaceSounds::COMMIT_PRESSED);
break;
default:
@@ -790,7 +790,7 @@ void gameplay_help_draw_text()
}
// gameplay_help_do_frame() is the function that displays help when acutally playing the game
void gameplay_help_do_frame(float frametime)
void gameplay_help_do_frame(float /*frametime*/)
{
int i, k;
+1 -1
View File
@@ -1340,7 +1340,7 @@ void parse_menumusic()
if(optional_string("$Filename:"))
{
stuff_string(fname, F_LNAME, MAX_FILENAME_LEN);
if ( strnicmp(fname, NOX("none.wav"), 4) ) {
if ( strnicmp(fname, NOX("none.wav"), 4) != 0 ) {
strcpy_s( Spooled_music[idx].filename, fname );
}
else
+97 -97
View File
@@ -8,7 +8,7 @@
*/
#include <sstream>
#include <limits.h>
#include <climits>
#include "gamesnd/gamesnd.h"
#include "localization/localize.h"
@@ -258,12 +258,12 @@ void gamesnd_add_retail_default_enhanced_sound_data()
}
}
void gamesnd_play_iface(int n)
void gamesnd_play_iface(interface_snd_id n)
{
if (Snds_iface_handle[n] >= 0)
snd_stop(Snds_iface_handle[n]);
if (Snds_iface_handle[n.value()] >= 0)
snd_stop(Snds_iface_handle[n.value()]);
Snds_iface_handle[n] = snd_play(gamesnd_get_interface_sound(n));
Snds_iface_handle[n.value()] = snd_play(gamesnd_get_interface_sound(n));
}
/**
@@ -288,7 +288,7 @@ int gamesnd_lookup_name(const char* name, const SCP_vector<game_snd>& sounds)
for(SCP_vector<game_snd>::const_iterator snd = sounds.begin(); snd != sounds.end(); ++snd)
{
if (!snd->name.compare(name))
if (snd->name == name)
{
return i;
}
@@ -299,7 +299,7 @@ int gamesnd_lookup_name(const char* name, const SCP_vector<game_snd>& sounds)
}
// WMC - now ignores file extension.
int gamesnd_get_by_name(const char* name)
gamesnd_id gamesnd_get_by_name(const char* name)
{
Assert( Snds.size() <= INT_MAX );
@@ -308,14 +308,13 @@ int gamesnd_get_by_name(const char* name)
if (index < 0)
{
int i = 0;
for(SCP_vector<game_snd>::iterator snd = Snds.begin(); snd != Snds.end(); ++snd)
{
if (snd->sound_entries.size() != 1) {
for (auto& Snd : Snds) {
if (Snd.sound_entries.size() != 1) {
// Ignore game sounds with more than one sound entry
continue;
}
auto& entry = snd->sound_entries.front();
auto& entry = Snd.sound_entries.front();
char *p = strrchr( entry.filename, '.' );
if(p == NULL)
{
@@ -335,27 +334,26 @@ int gamesnd_get_by_name(const char* name)
}
}
return index;
return gamesnd_id(index);
}
int gamesnd_get_by_iface_name(const char* name)
interface_snd_id gamesnd_get_by_iface_name(const char* name)
{
Assert( Snds_iface.size() <= INT_MAX );
Assert( Snds_iface.size() == Snds_iface_handle.size() );
int index = gamesnd_lookup_name(name, Snds_iface);
auto index = gamesnd_lookup_name(name, Snds_iface);
if (index < 0)
{
int i = 0;
for(SCP_vector<game_snd>::iterator snd = Snds_iface.begin(); snd != Snds_iface.end(); ++snd)
{
if (snd->sound_entries.size() != 1) {
for (auto& snd : Snds_iface) {
if (snd.sound_entries.size() != 1) {
// Ignore game sounds with more than one sound entry
continue;
}
auto& entry = snd->sound_entries.front();
auto& entry = snd.sound_entries.front();
char *p = strrchr( entry.filename, '.' );
if(p == NULL)
{
@@ -375,71 +373,36 @@ int gamesnd_get_by_iface_name(const char* name)
}
}
return index;
return interface_snd_id(index);
}
int gamesnd_get_by_tbl_index(int index)
gamesnd_id gamesnd_get_by_tbl_index(int index)
{
char temp[11];
sprintf(temp, "%i", index);
return gamesnd_lookup_name(temp, Snds);
auto idx = gamesnd_lookup_name(temp, Snds);
if (idx < 0) {
return gamesnd_id();
} else {
return gamesnd_id(idx);
}
}
int gamesnd_get_by_iface_tbl_index(int index)
interface_snd_id gamesnd_get_by_iface_tbl_index(int index)
{
Assert( Snds_iface.size() == Snds_iface_handle.size() );
char temp[11];
sprintf(temp, "%i", index);
return gamesnd_lookup_name(temp, Snds_iface);
}
auto idx = gamesnd_lookup_name(temp, Snds_iface);
/**
* Helper function for parse_sound and parse_sound_list. Do not use directly.
*
* @param tag Tag
* @param idx_dest Sound index destination
* @param object_name Object name being parsed
* @param buf Buffer holding string to be parsed
* @param flags See the parse_sound_flags enum
*
*/
void parse_sound_core(const char* tag, int *idx_dest, const char* object_name, const char* buf, parse_sound_flags flags)
{
int idx;
if(flags & PARSE_SOUND_INTERFACE_SOUND)
idx = gamesnd_get_by_iface_name(buf);
else
idx = gamesnd_get_by_name(buf);
if(idx != -1)
{
(*idx_dest) = idx;
}
size_t size_to_check = 0;
if(flags & PARSE_SOUND_INTERFACE_SOUND)
{
size_to_check = Snds_iface.size();
Assert( Snds_iface.size() == Snds_iface_handle.size() );
}
else
{
size_to_check = Snds.size();
}
Assert( size_to_check <= INT_MAX );
//Ensure sound is in range
if((*idx_dest) < -1 || (*idx_dest) >= (int)size_to_check)
{
(*idx_dest) = -1;
Warning(LOCATION, "%s sound index out of range on '%s'. Must be between 0 and " SIZE_T_ARG ". Forcing to -1 (Nonexistent sound).\n",
tag, object_name, size_to_check);
if (idx < 0) {
return interface_snd_id();
} else {
return interface_snd_id(idx);
}
}
@@ -451,18 +414,49 @@ void parse_sound_core(const char* tag, int *idx_dest, const char* object_name, c
*
* @param tag Tag
* @param idx_dest Sound index destination
* @param object_name Object name being parsed
* @param flags See the parse_sound_flags enum
*
*/
void parse_sound(const char* tag, int *idx_dest, const char* object_name, parse_sound_flags flags)
{
void parse_game_sound(const char* tag, gamesnd_id* idx_dest) {
if(optional_string(tag))
{
char buf[MAX_FILENAME_LEN];
stuff_string(buf, F_NAME, MAX_FILENAME_LEN);
SCP_string buf;
stuff_string(buf, F_NAME);
parse_sound_core(tag, idx_dest, object_name, buf, flags);
*idx_dest = gamesnd_get_by_name(buf.c_str());
// The special case "-1" is needed to silence warnings where sounds are intentionally removed
if (!idx_dest->isValid() && buf != "-1") {
error_display(0, "Could not find game sound with name '%s'!", buf.c_str());
}
}
}
/**
* Parse a sound. When using this function for a table entry,
* required_string and optional_string aren't needed, as this function deals with
* that as its tag parameter, just make sure that the destination sound index can
* handle -1 if things don't work out.
*
* @param tag Tag
* @param idx_dest Sound index destination
* @param flags See the parse_sound_flags enum
*
*/
void parse_iface_sound(const char* tag, interface_snd_id* idx_dest) {
Assert( Snds_iface.size() == Snds_iface_handle.size() );
if(optional_string(tag))
{
SCP_string buf;
stuff_string(buf, F_NAME);
*idx_dest = gamesnd_get_by_iface_name(buf.c_str());
// The special case "-1" is needed to silence warnings where sounds are intentionally removed
if (!idx_dest->isValid() && buf != "-1") {
error_display(0, "Could not find interface sound with name '%s'!", buf.c_str());
}
}
}
@@ -478,14 +472,14 @@ void parse_sound(const char* tag, int *idx_dest, const char* object_name, parse_
* @param flags See the parse_sound_flags enum
*
*/
void parse_sound_list(const char* tag, SCP_vector<int>& destination, const char* object_name, parse_sound_flags flags)
void parse_iface_sound_list(const char* tag, SCP_vector<interface_snd_id>& destination, const char* object_name, bool scp_list)
{
if(optional_string(tag))
{
int check=0;
//if we're using the old format, parse the first entry separately
if(!(flags & PARSE_SOUND_SCP_SOUND_LIST))
if(!scp_list)
{
stuff_int(&check);
}
@@ -493,20 +487,24 @@ void parse_sound_list(const char* tag, SCP_vector<int>& destination, const char*
//now read the rest of the entries on the line
for(size_t i=0; !check_for_eoln(); i++)
{
char buf[MAX_FILENAME_LEN];
stuff_string_white(buf, MAX_FILENAME_LEN);
SCP_string buf;
stuff_string_white(buf);
//we do this conditionally to avoid adding needless entries when reparsing
if(destination.size() <= i)
{
destination.push_back(-1);
destination.push_back(interface_snd_id());
}
parse_sound_core(tag, &destination.at(i), object_name, buf, flags);
destination[i] = gamesnd_get_by_iface_name(buf.c_str());
if (!destination[i].isValid()) {
error_display(0, "Could not find interface sound with name '%s'!", buf.c_str());
}
}
//if we're using the old format, double check the size)
if(!(flags & PARSE_SOUND_SCP_SOUND_LIST) && (destination.size() != (unsigned)check))
if(!scp_list && (destination.size() != (unsigned)check))
{
mprintf(("%s in '%s' has " SIZE_T_ARG " entries. This does not match entered size of %i.", tag, object_name, destination.size(), check));
}
@@ -529,7 +527,7 @@ void gamesnd_preload_common_sounds()
for (SCP_vector<game_snd>::iterator gs = Snds.begin(); gs != Snds.end(); ++gs) {
if ( gs->preload ) {
for (auto& entry : gs->sound_entries) {
if ( entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4) ) {
if ( entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4) != 0 ) {
game_busy( NOX("** preloading common game sounds **") ); // Animate loading cursor... does nothing if loading screen not active.
entry.id = snd_load(&entry, gs->flags);
}
@@ -550,7 +548,7 @@ void gamesnd_load_gameplay_sounds()
for (SCP_vector<game_snd>::iterator gs = Snds.begin(); gs != Snds.end(); ++gs) {
if ( !gs->preload ) { // don't try to load anything that's already preloaded
for (auto& entry : gs->sound_entries) {
if (entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4)) {
if (entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4) != 0) {
game_busy(NOX("** preloading gameplay sounds **")); // Animate loading cursor... does nothing if loading screen not active.
entry.id = snd_load(&entry, gs->flags);
}
@@ -586,7 +584,7 @@ void gamesnd_load_interface_sounds()
Assert( Snds_iface.size() < INT_MAX );
for (SCP_vector<game_snd>::iterator si = Snds_iface.begin(); si != Snds_iface.end(); ++si) {
for (auto& entry : si->sound_entries) {
if ( entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4) ) {
if ( entry.filename[0] != 0 && strnicmp(entry.filename, NOX("none.wav"), 4) != 0 ) {
entry.id = snd_load(&entry, si->flags);
}
}
@@ -849,7 +847,7 @@ void parse_gamesnd_new(game_snd* gs, bool no_create)
}
// If the name _doesn't_ match <same> put it into gs->filename;
if (stricmp(name, "<same>"))
if (stricmp(name, "<same>") != 0)
{
strcpy_s(entry->filename, name);
}
@@ -1291,7 +1289,7 @@ void gamesnd_close()
*/
void common_play_highlight_sound()
{
gamesnd_play_iface(SND_USER_OVER);
gamesnd_play_iface(InterfaceSounds::USER_OVER);
}
/**
@@ -1299,23 +1297,25 @@ void common_play_highlight_sound()
*/
void gamesnd_play_error_beep()
{
gamesnd_play_iface(SND_GENERAL_FAIL);
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
}
game_snd* gamesnd_get_game_sound(int handle) {
Assertion(handle >= 0 && handle < (int) Snds.size(), "Invalid game sound handle %d detected!", handle);
return &Snds[handle];
game_snd* gamesnd_get_game_sound(gamesnd_id handle) {
Assertion(handle.isValid(), "Invalid game sound handle detected!");
Assertion(handle.value() < (int) Snds.size(), "Invalid game sound handle %d detected!", handle.value());
return &Snds[handle.value()];
}
game_snd* gamesnd_get_interface_sound(int handle) {
Assertion(handle >= 0 && handle < (int) Snds_iface.size(), "Invalid interface sound handle %d detected!", handle);
return &Snds_iface[handle];
game_snd* gamesnd_get_interface_sound(interface_snd_id handle) {
Assertion(handle.isValid(), "Invalid interface sound handle detected!");
Assertion(handle.value() < (int) Snds_iface.size(), "Invalid interface sound handle %d detected!", handle.value());
return &Snds_iface[handle.value()];
}
bool gamesnd_game_sound_valid(int sound) {
return sound >= 0 && sound < (int) Snds.size();
bool gamesnd_game_sound_valid(gamesnd_id sound) {
return sound.isValid() && sound.value() < (int) Snds.size();
}
bool gamesnd_interface_sound_valid(int sound) {
return sound >= 0 && sound < (int) Snds_iface.size();
bool gamesnd_interface_sound_valid(interface_snd_id sound) {
return sound.isValid() && sound.value() < (int) Snds_iface.size();
}
float gamesnd_get_max_duration(game_snd* gs) {
+335 -310
View File
@@ -12,42 +12,8 @@
#ifndef __GAMESND_H__
#define __GAMESND_H__
#include "mission/missionparse.h"
#include "sound/sound.h"
void gamesnd_parse_soundstbl(); // Loads in general game sounds from sounds.tbl
void gamesnd_close(); // close out gamesnd... only call from game_shutdown()!
void gamesnd_load_gameplay_sounds();
void gamesnd_unload_gameplay_sounds();
void gamesnd_load_interface_sounds();
void gamesnd_unload_interface_sounds();
void gamesnd_preload_common_sounds();
void gamesnd_load_gameplay_sounds();
void gamesnd_unload_gameplay_sounds();
void gamesnd_play_iface(int n);
void gamesnd_play_error_beep();
int gamesnd_get_by_name(const char* name);
int gamesnd_get_by_iface_name(const char* name);
int gamesnd_get_by_tbl_index(int index);
int gamesnd_get_by_iface_tbl_index(int index);
//flags for parse_sound and parse_sound_list
enum parse_sound_flags
{
PARSE_SOUND_GENERAL_SOUND = 0, //!< search for sound in the general table in sound.tbl
PARSE_SOUND_INTERFACE_SOUND = (1 << 0), //!< Search for sound in the interface part of sounds.tbl
PARSE_SOUND_SCP_SOUND_LIST = (1 << 1), //!< Parse the list of sounds SCP style (just indexes and/or files names, no count first)
PARSE_SOUND_MAX
};
//This should handle NO_SOUND just fine since it doesn't directly access lowlevel code
//Does all parsing for a sound
void parse_sound(const char* tag, int* idx_dest, const char* object_name, parse_sound_flags = PARSE_SOUND_GENERAL_SOUND);
void parse_sound_list(const char* tag, SCP_vector<int>& destination, const char* object_name, parse_sound_flags = PARSE_SOUND_GENERAL_SOUND);
// this is a callback, so it needs to be a real function
void common_play_highlight_sound();
#include "utils/id.h"
/**
* symbolic names for misc. game sounds.
@@ -61,325 +27,384 @@ void common_play_highlight_sound();
* Then add a symbolic name to the appropriate position in the enum below
* and add an entry to sounds.tbl. If there is no .wav file for the sound yet, specify sound_hook.wav in sounds.tbl.
*/
enum GameSoundsIndex {
SND_MISSILE_TRACKING = 0, //!< Missle tracking to acquire a lock (looped)
SND_MISSILE_LOCK = 1, //!< Missle lock (non-looping)
SND_PRIMARY_CYCLE = 2, //!< cycle primary weapon
SND_SECONDARY_CYCLE = 3, //!< cycle secondary weapon
SND_ENGINE = 4, //!< engine sound (as heard in cockpit)
SND_CARGO_REVEAL = 5, //!< cargo revealed
SND_DEATH_ROLL = 6, //!< ship death roll
SND_SHIP_EXPLODE_1 = 7, //!< ship explosion 1
SND_TARGET_ACQUIRE = 8, //!< target acquried
SND_ENERGY_ADJUST = 9, //!< energy level change success
SND_ENERGY_ADJUST_FAIL = 10, //!< energy level change fail
SND_ENERGY_TRANS = 11, //!< energy transfer success
SND_ENERGY_TRANS_FAIL = 12, //!< energy transfer fail
SND_FULL_THROTTLE = 13, //!< set full throttle
SND_ZERO_THROTTLE = 14, //!< set zero throttle
SND_THROTTLE_UP = 15, //!< set 1/3 or 2/3 throttle (up)
SND_THROTTLE_DOWN = 16, //!< set 1/3 or 2/3 throttle (down)
SND_DOCK_APPROACH = 17, //!< dock approach retros
SND_DOCK_ATTACH = 18, //!< dock attach
SND_DOCK_DETACH = 19, //!< dock detach
SND_DOCK_DEPART = 20, //!< dock depart retros
SND_ABURN_ENGAGE = 21, //!< afterburner engage
SND_ABURN_LOOP = 22, //!< afterburner burn sound (looped)
SND_VAPORIZED = 23, //!< Destroyed by a beam (vaporized)
SND_ABURN_FAIL = 24, //!< afterburner fail (no fuel when aburn pressed)
SND_HEATLOCK_WARN = 25, //!< heat-seeker launch warning
SND_OUT_OF_MISSLES = 26, //!< tried to fire a missle when none are left
SND_OUT_OF_WEAPON_ENERGY = 27, //!< tried to fire lasers when not enough energy left
SND_TARGET_FAIL = 28, //!< target fail sound (i.e. press targeting key, but nothing happens)
SND_SQUADMSGING_ON = 29, //!< squadmate message menu appears
SND_SQUADMSGING_OFF = 30, //!< squadmate message menu disappears
SND_DEBRIS = 31, //!< debris sound (persistant, looping)
SND_SUBSYS_DIE_1 = 32, //!< subsystem gets destroyed on player ship
SND_MISSILE_START_LOAD = 33, //!< missle start load (during rearm/repair)
SND_MISSILE_LOAD = 34, //!< missle load (during rearm/repair)
SND_SHIP_REPAIR = 35, //!< ship is being repaired (during rearm/repair)
SND_PLAYER_HIT_LASER = 36, //!< player ship is hit by laser fire
SND_PLAYER_HIT_MISSILE = 37, //!< player ship is hit by missile
SND_CMEASURE_CYCLE = 38, //!< countermeasure cycle
SND_SHIELD_HIT = 39, //!< shield hit
SND_SHIELD_HIT_YOU = 40, //!< player shield is hit
SND_GAME_MOUSE_CLICK = 41, //!< mouse click
SND_ASPECTLOCK_WARN = 42, //!< aspect launch warning
SND_SHIELD_XFER_OK = 43, //!< shield quadrant transfer successful
SND_ENGINE_WASH = 44, //!< Engine wash (looped)
SND_WARP_IN = 45, //!< warp hole opening up for arriving
SND_WARP_OUT = 46, //!< warp hole opening up for departing (Same as warp in for now)
SND_PLAYER_WARP_FAIL = 47, //!< player warp has failed
SND_STATIC = 48, //!< hud gauge static
SND_SHIP_EXPLODE_2 = 49, //!< ship explosion 2
SND_PLAYER_WARP_OUT = 50, //!< ship is warping out in 3rd person
SND_SHIP_SHIP_HEAVY = 51, //!< heavy ship-ship collide sound
SND_SHIP_SHIP_LIGHT = 52, //!< light ship-ship collide sound
SND_SHIP_SHIP_SHIELD = 53, //!< shield ship-ship collide overlay sound
SND_THREAT_FLASH = 54, //!< missile threat indicator flashes
SND_PROXIMITY_WARNING = 55, //!< proximity warning (heat seeker)
SND_PROXIMITY_ASPECT_WARNING = 56, //!< proximity warning (aspect)
SND_DIRECTIVE_COMPLETE = 57, //!< directive complete
SND_SUBSYS_EXPLODE = 58, //!< other ship subsystem destroyed
SND_CAPSHIP_EXPLODE = 59, //!< captial ship explosion
SND_CAPSHIP_SUBSYS_EXPLODE = 60, //!< captial ship subsystem destroyed
SND_LARGESHIP_WARPOUT = 61, //!< large ship warps out
SND_ASTEROID_EXPLODE_LARGE = 62, //!< large asteroid blows up
SND_ASTEROID_EXPLODE_SMALL = 63, //!< small asteroid blows up
SND_CUE_VOICE = 64, //!< sound to indicate voice is about to start
SND_END_VOICE = 65, //!< sound to indicate voice has ended
SND_CARGO_SCAN = 66, //!< cargo scanning (looped)
SND_WEAPON_FLYBY = 67, //!< weapon flyby sound
SND_ASTEROID = 68, //!< asteroid sound (persistant, looped)
SND_CAPITAL_WARP_IN = 69, //!< capital warp hole opening
SND_CAPITAL_WARP_OUT = 70, //!< capital warp hole closing
SND_ENGINE_LOOP_LARGE = 71, //!< LARGE engine ambient
SND_SUBSPACE_LEFT_CHANNEL = 72, //!< subspace ambient sound (left channel) (looped)
SND_SUBSPACE_RIGHT_CHANNEL = 73, //!< subspace ambient sound (right channel) (looped)
SND_MISSILE_EVADED_POPUP = 74, //!< "evaded" HUD popup
SND_ENGINE_LOOP_HUGE = 75, //!< HUGE engine ambient
enum class GameSounds {
MISSILE_TRACKING = 0, //!< Missle tracking to acquire a lock (looped)
MISSILE_LOCK = 1, //!< Missle lock (non-looping)
PRIMARY_CYCLE = 2, //!< cycle primary weapon
SECONDARY_CYCLE = 3, //!< cycle secondary weapon
ENGINE = 4, //!< engine sound (as heard in cockpit)
CARGO_REVEAL = 5, //!< cargo revealed
DEATH_ROLL = 6, //!< ship death roll
SHIP_EXPLODE_1 = 7, //!< ship explosion 1
TARGET_ACQUIRE = 8, //!< target acquried
ENERGY_ADJUST = 9, //!< energy level change success
ENERGY_ADJUST_FAIL = 10, //!< energy level change fail
ENERGY_TRANS = 11, //!< energy transfer success
ENERGY_TRANS_FAIL = 12, //!< energy transfer fail
FULL_THROTTLE = 13, //!< set full throttle
ZERO_THROTTLE = 14, //!< set zero throttle
THROTTLE_UP = 15, //!< set 1/3 or 2/3 throttle (up)
THROTTLE_DOWN = 16, //!< set 1/3 or 2/3 throttle (down)
DOCK_APPROACH = 17, //!< dock approach retros
DOCK_ATTACH = 18, //!< dock attach
DOCK_DETACH = 19, //!< dock detach
DOCK_DEPART = 20, //!< dock depart retros
ABURN_ENGAGE = 21, //!< afterburner engage
ABURN_LOOP = 22, //!< afterburner burn sound (looped)
VAPORIZED = 23, //!< Destroyed by a beam (vaporized)
ABURN_FAIL = 24, //!< afterburner fail (no fuel when aburn pressed)
HEATLOCK_WARN = 25, //!< heat-seeker launch warning
OUT_OF_MISSLES = 26, //!< tried to fire a missle when none are left
OUT_OF_WEAPON_ENERGY = 27, //!< tried to fire lasers when not enough energy left
TARGET_FAIL = 28, //!< target fail sound (i.e. press targeting key, but nothing happens)
SQUADMSGING_ON = 29, //!< squadmate message menu appears
SQUADMSGING_OFF = 30, //!< squadmate message menu disappears
DEBRIS = 31, //!< debris sound (persistant, looping)
SUBSYS_DIE_1 = 32, //!< subsystem gets destroyed on player ship
MISSILE_START_LOAD = 33, //!< missle start load (during rearm/repair)
MISSILE_LOAD = 34, //!< missle load (during rearm/repair)
SHIP_REPAIR = 35, //!< ship is being repaired (during rearm/repair)
PLAYER_HIT_LASER = 36, //!< player ship is hit by laser fire
PLAYER_HIT_MISSILE = 37, //!< player ship is hit by missile
CMEASURE_CYCLE = 38, //!< countermeasure cycle
SHIELD_HIT = 39, //!< shield hit
SHIELD_HIT_YOU = 40, //!< player shield is hit
GAME_MOUSE_CLICK = 41, //!< mouse click
ASPECTLOCK_WARN = 42, //!< aspect launch warning
SHIELD_XFER_OK = 43, //!< shield quadrant transfer successful
ENGINE_WASH = 44, //!< Engine wash (looped)
WARP_IN = 45, //!< warp hole opening up for arriving
WARP_OUT = 46, //!< warp hole opening up for departing (Same as warp in for now)
PLAYER_WARP_FAIL = 47, //!< player warp has failed
STATIC = 48, //!< hud gauge static
SHIP_EXPLODE_2 = 49, //!< ship explosion 2
PLAYER_WARP_OUT = 50, //!< ship is warping out in 3rd person
SHIP_SHIP_HEAVY = 51, //!< heavy ship-ship collide sound
SHIP_SHIP_LIGHT = 52, //!< light ship-ship collide sound
SHIP_SHIP_SHIELD = 53, //!< shield ship-ship collide overlay sound
THREAT_FLASH = 54, //!< missile threat indicator flashes
PROXIMITY_WARNING = 55, //!< proximity warning (heat seeker)
PROXIMITY_ASPECT_WARNING = 56, //!< proximity warning (aspect)
DIRECTIVE_COMPLETE = 57, //!< directive complete
SUBSYS_EXPLODE = 58, //!< other ship subsystem destroyed
CAPSHIP_EXPLODE = 59, //!< captial ship explosion
CAPSHIP_SUBSYS_EXPLODE = 60, //!< captial ship subsystem destroyed
LARGESHIP_WARPOUT = 61, //!< large ship warps out
ASTEROID_EXPLODE_LARGE = 62, //!< large asteroid blows up
ASTEROID_EXPLODE_SMALL = 63, //!< small asteroid blows up
CUE_VOICE = 64, //!< sound to indicate voice is about to start
END_VOICE = 65, //!< sound to indicate voice has ended
CARGO_SCAN = 66, //!< cargo scanning (looped)
WEAPON_FLYBY = 67, //!< weapon flyby sound
ASTEROID = 68, //!< asteroid sound (persistant, looped)
CAPITAL_WARP_IN = 69, //!< capital warp hole opening
CAPITAL_WARP_OUT = 70, //!< capital warp hole closing
ENGINE_LOOP_LARGE = 71, //!< LARGE engine ambient
SUBSPACE_LEFT_CHANNEL = 72, //!< subspace ambient sound (left channel) (looped)
SUBSPACE_RIGHT_CHANNEL = 73, //!< subspace ambient sound (right channel) (looped)
MISSILE_EVADED_POPUP = 74, //!< "evaded" HUD popup
ENGINE_LOOP_HUGE = 75, //!< HUGE engine ambient
//Weapons section
SND_LIGHT_LASER_FIRE = 76, //!< SD-4 Sidearm laser fired
SND_LIGHT_LASER_IMPACT = 77, //!< DR-2 Scalpel fired
SND_HVY_LASER_FIRE = 78, //!< Flail II fired
SND_HVY_LASER_IMPACT = 79, //!< Prometheus R laser fired
SND_MASSDRV_FIRED = 80, //!< Prometheus S laser fired
SND_MASSDRV_IMPACT = 81, //!< GTW-66 Newton Cannon fired
SND_FLAIL_FIRED = 82, //!< UD-8 Kayser Laser fired
SND_FLAIL_IMPACT = 83, //!< GTW-19 Circe laser fired
SND_NEUTRON_FLUX_FIRED = 84, //!< GTW-83 Lich laser fired
SND_NEUTRON_FLUX_IMPACT = 85, //!< Laser impact
SND_DEBUG_LASER_FIRED = 86, //!< Subach-HLV Vasudan laser
SND_ROCKEYE_FIRED = 87, //!< rockeye missile launch
SND_MISSILE_IMPACT1 = 88, //!< missile impact 1
SND_MAG_MISSILE_LAUNCH = 89, //!< mag pulse missile launch
SND_FURY_MISSILE_LAUNCH = 90, //!< fury missile launch
SND_SHRIKE_MISSILE_LAUNCH = 91, //!< shrike missile launch
SND_ANGEL_MISSILE_LAUNCH = 92, //!< angel fire missile launch
SND_CLUSTER_MISSILE_LAUNCH = 93, //!< cluster bomb launch
SND_CLUSTERB_MISSILE_LAUNCH = 94, //!< cluster baby bomb launch
SND_STILETTO_MISSILE_LAUNCH = 95, //!< stiletto bomb launch
SND_TSUNAMI_MISSILE_LAUNCH = 96, //!< tsunami bomb launch
SND_HARBINGER_MISSILE_LAUNCH = 97, //!< harbinger bomb launch
SND_MEGAWOKKA_MISSILE_LAUNCH = 98, //!< mega wokka launch
SND_CMEASURE1_LAUNCH = 99, //!< countermeasure 1 launch
SND_SHIVAN_LIGHT_LASER_FIRE = 100,//!< Shivan light laser
SND_SHOCKWAVE_EXPLODE = 101,//!< shockwave ignition
SND_SWARM_MISSILE_LAUNCH = 102,//!< swarm missile sound
SND_UNDEFINED_103 = 103,//!< Shivan heavy laser
SND_UNDEFINED_104 = 104,//!< Vasudan SuperCap engine
SND_UNDEFINED_105 = 105,//!< Shivan SuperCap engine
SND_UNDEFINED_106 = 106,//!< Terran SuperCap engine
SND_UNDEFINED_107 = 107,//!< Vasudan light laser fired
SND_UNDEFINED_108 = 108,//!< Shivan heavy laser
SND_SHOCKWAVE_IMPACT = 109,//!< shockwave impact
SND_UNDEFINED_110 = 110,//!< TERRAN TURRET 1
SND_UNDEFINED_111 = 111,//!< TERRAN TURRET 2
SND_UNDEFINED_112 = 112,//!< VASUDAN TURRET 1
SND_UNDEFINED_113 = 113,//!< VASUDAN TURRET 2
SND_UNDEFINED_114 = 114,//!< SHIVAN TURRET 1
SND_TARG_LASER_LOOP = 115,//!< targeting laser loop sound
SND_FLAK_FIRE = 116,//!< Flak Gun Launch
SND_SHIELD_BREAKER = 117,//!< Flak Gun Impact
SND_EMP_MISSILE = 118,//!< EMP Missle
SND_AUTOCANNON_LOOP = 119,//!< Escape Pod Drone
SND_AUTOCANNON_SHOT = 120,//!< Beam Hit 1
SND_BEAM_LOOP = 121,//!< beam loop
SND_BEAM_UP = 122,//!< beam power up
SND_BEAM_DOWN = 123,//!< beam power down
SND_BEAM_SHOT = 124,//!< Beam shot 1
SND_BEAM_VAPORIZE = 125,//!< Beam shot 2
LIGHT_LASER_FIRE = 76, //!< SD-4 Sidearm laser fired
LIGHT_LASER_IMPACT = 77, //!< DR-2 Scalpel fired
HVY_LASER_FIRE = 78, //!< Flail II fired
HVY_LASER_IMPACT = 79, //!< Prometheus R laser fired
MASSDRV_FIRED = 80, //!< Prometheus S laser fired
MASSDRV_IMPACT = 81, //!< GTW-66 Newton Cannon fired
FLAIL_FIRED = 82, //!< UD-8 Kayser Laser fired
FLAIL_IMPACT = 83, //!< GTW-19 Circe laser fired
NEUTRON_FLUX_FIRED = 84, //!< GTW-83 Lich laser fired
NEUTRON_FLUX_IMPACT = 85, //!< Laser impact
DEBUG_LASER_FIRED = 86, //!< Subach-HLV Vasudan laser
ROCKEYE_FIRED = 87, //!< rockeye missile launch
MISSILE_IMPACT1 = 88, //!< missile impact 1
MAG_MISSILE_LAUNCH = 89, //!< mag pulse missile launch
FURY_MISSILE_LAUNCH = 90, //!< fury missile launch
SHRIKE_MISSILE_LAUNCH = 91, //!< shrike missile launch
ANGEL_MISSILE_LAUNCH = 92, //!< angel fire missile launch
CLUSTER_MISSILE_LAUNCH = 93, //!< cluster bomb launch
CLUSTERB_MISSILE_LAUNCH = 94, //!< cluster baby bomb launch
STILETTO_MISSILE_LAUNCH = 95, //!< stiletto bomb launch
TSUNAMI_MISSILE_LAUNCH = 96, //!< tsunami bomb launch
HARBINGER_MISSILE_LAUNCH = 97, //!< harbinger bomb launch
MEGAWOKKA_MISSILE_LAUNCH = 98, //!< mega wokka launch
CMEASURE1_LAUNCH = 99, //!< countermeasure 1 launch
SHIVAN_LIGHT_LASER_FIRE = 100,//!< Shivan light laser
SHOCKWAVE_EXPLODE = 101,//!< shockwave ignition
SWARM_MISSILE_LAUNCH = 102,//!< swarm missile sound
UNDEFINED_103 = 103,//!< Shivan heavy laser
UNDEFINED_104 = 104,//!< Vasudan SuperCap engine
UNDEFINED_105 = 105,//!< Shivan SuperCap engine
UNDEFINED_106 = 106,//!< Terran SuperCap engine
UNDEFINED_107 = 107,//!< Vasudan light laser fired
UNDEFINED_108 = 108,//!< Shivan heavy laser
SHOCKWAVE_IMPACT = 109,//!< shockwave impact
UNDEFINED_110 = 110,//!< TERRAN TURRET 1
UNDEFINED_111 = 111,//!< TERRAN TURRET 2
UNDEFINED_112 = 112,//!< VASUDAN TURRET 1
UNDEFINED_113 = 113,//!< VASUDAN TURRET 2
UNDEFINED_114 = 114,//!< SHIVAN TURRET 1
TARG_LASER_LOOP = 115,//!< targeting laser loop sound
FLAK_FIRE = 116,//!< Flak Gun Launch
SHIELD_BREAKER = 117,//!< Flak Gun Impact
EMP_MISSILE = 118,//!< EMP Missle
AUTOCANNON_LOOP = 119,//!< Escape Pod Drone
AUTOCANNON_SHOT = 120,//!< Beam Hit 1
BEAM_LOOP = 121,//!< beam loop
BEAM_UP = 122,//!< beam power up
BEAM_DOWN = 123,//!< beam power down
BEAM_SHOT = 124,//!< Beam shot 1
BEAM_VAPORIZE = 125,//!< Beam shot 2
//Ship Engine Sounds section
SND_TERRAN_FIGHTER_ENG = 126,//!< Terran fighter engine
SND_TERRAN_BOMBER_ENG = 127,//!< Terran bomber engine
SND_TERRAN_CAPITAL_ENG = 128,//!< Terran cruiser engine
SND_SPECIESB_FIGHTER_ENG = 129,//!< Vasudan fighter engine
SND_SPECIESB_BOMBER_ENG = 130,//!< Vasudan bomber engine
SND_SPECIESB_CAPITAL_ENG = 131,//!< Vasudan cruiser engine
SND_SHIVAN_FIGHTER_ENG = 132,//!< Shivan fighter engine
SND_SHIVAN_BOMBER_ENG = 133,//!< Shivan bomber engine
SND_SHIVAN_CAPITAL_ENG = 134,//!< Shivan cruiser engine
SND_REPAIR_SHIP_ENG = 135,//!< Repair ship beacon/engine sound
SND_UNDEFINED_136 = 136,//!< Terran capital engine
SND_UNDEFINED_137 = 137,//!< Vasudan capital engine
SND_UNDEFINED_138 = 138,//!< Shivan capital engine
TERRAN_FIGHTER_ENG = 126,//!< Terran fighter engine
TERRAN_BOMBER_ENG = 127,//!< Terran bomber engine
TERRAN_CAPITAL_ENG = 128,//!< Terran cruiser engine
SPECIESB_FIGHTER_ENG = 129,//!< Vasudan fighter engine
SPECIESB_BOMBER_ENG = 130,//!< Vasudan bomber engine
SPECIESB_CAPITAL_ENG = 131,//!< Vasudan cruiser engine
SHIVAN_FIGHTER_ENG = 132,//!< Shivan fighter engine
SHIVAN_BOMBER_ENG = 133,//!< Shivan bomber engine
SHIVAN_CAPITAL_ENG = 134,//!< Shivan cruiser engine
REPAIR_SHIP_ENG = 135,//!< Repair ship beacon/engine sound
UNDEFINED_136 = 136,//!< Terran capital engine
UNDEFINED_137 = 137,//!< Vasudan capital engine
UNDEFINED_138 = 138,//!< Shivan capital engine
// Electrical arc sound fx on the debris pieces
SND_DEBRIS_ARC_01 = 139,//!< 0.10 second spark sound effect
SND_DEBRIS_ARC_02 = 140,//!< 0.25 second spark sound effect
SND_DEBRIS_ARC_03 = 141,//!< 0.50 second spark sound effect
SND_DEBRIS_ARC_04 = 142,//!< 0.75 second spark sound effect
SND_DEBRIS_ARC_05 = 143,//!< 1.00 second spark sound effect
DEBRIS_ARC_01 = 139,//!< 0.10 second spark sound effect
DEBRIS_ARC_02 = 140,//!< 0.25 second spark sound effect
DEBRIS_ARC_03 = 141,//!< 0.50 second spark sound effect
DEBRIS_ARC_04 = 142,//!< 0.75 second spark sound effect
DEBRIS_ARC_05 = 143,//!< 1.00 second spark sound effect
// Beam Sounds
SND_UNDEFINED_144 = 144,//!< LTerSlash beam loop
SND_UNDEFINED_145 = 145,//!< TerSlash beam loop
SND_UNDEFINED_146 = 146,//!< SGreen beam loop
SND_UNDEFINED_147 = 147,//!< BGreen beem loop
SND_UNDEFINED_148 = 148,//!< BFGreen been loop
SND_UNDEFINED_149 = 149,//!< Antifighter beam loop
SND_UNDEFINED_150 = 150,//!< 1 sec warm up
SND_UNDEFINED_151 = 151,//!< 1.5 sec warm up
SND_UNDEFINED_152 = 152,//!< 2.5 sec warm up
SND_UNDEFINED_153 = 153,//!< 3 sec warm up
SND_UNDEFINED_154 = 154,//!< 3.5 sec warm up
SND_UNDEFINED_155 = 155,//!< 5 sec warm up
SND_UNDEFINED_156 = 156,//!< LTerSlash warm down
SND_UNDEFINED_157 = 157,//!< TerSlash warm down
SND_UNDEFINED_158 = 158,//!< SGreen warm down
SND_UNDEFINED_159 = 159,//!< BGreen warm down
SND_UNDEFINED_160 = 160,//!< BFGreen warm down
SND_UNDEFINED_161 = 161,//!< T_AntiFtr warm down
UNDEFINED_144 = 144,//!< LTerSlash beam loop
UNDEFINED_145 = 145,//!< TerSlash beam loop
UNDEFINED_146 = 146,//!< SGreen beam loop
UNDEFINED_147 = 147,//!< BGreen beem loop
UNDEFINED_148 = 148,//!< BFGreen been loop
UNDEFINED_149 = 149,//!< Antifighter beam loop
UNDEFINED_150 = 150,//!< 1 sec warm up
UNDEFINED_151 = 151,//!< 1.5 sec warm up
UNDEFINED_152 = 152,//!< 2.5 sec warm up
UNDEFINED_153 = 153,//!< 3 sec warm up
UNDEFINED_154 = 154,//!< 3.5 sec warm up
UNDEFINED_155 = 155,//!< 5 sec warm up
UNDEFINED_156 = 156,//!< LTerSlash warm down
UNDEFINED_157 = 157,//!< TerSlash warm down
UNDEFINED_158 = 158,//!< SGreen warm down
UNDEFINED_159 = 159,//!< BGreen warm down
UNDEFINED_160 = 160,//!< BFGreen warm down
UNDEFINED_161 = 161,//!< T_AntiFtr warm down
SND_COPILOT = 162,//!< copilot (SCP)
SND_UNDEFINED_163 = 163,//!< (Empty in Retail)
SND_UNDEFINED_164 = 164,//!< (Empty in Retail)
SND_UNDEFINED_165 = 165,//!< (Empty in Retail)
SND_UNDEFINED_166 = 166,//!< (Empty in Retail)
SND_UNDEFINED_167 = 167,//!< (Empty in Retail)
SND_UNDEFINED_168 = 168,//!< (Empty in Retail)
SND_UNDEFINED_169 = 169,//!< (Empty in Retail)
SND_UNDEFINED_170 = 170,//!< (Empty in Retail)
SND_UNDEFINED_171 = 171,//!< (Empty in Retail)
SND_UNDEFINED_172 = 172,//!< (Empty in Retail)
SND_SUPERNOVA_1 = 173,//!< SuperNova (distant)
SND_SUPERNOVA_2 = 174,//!< SuperNova (shockwave)
SND_UNDEFINED_175 = 175,//!< Shivan large engine
SND_UNDEFINED_176 = 176,//!< Shivan large engine
SND_UNDEFINED_177 = 177,//!< SRed beam loop
SND_UNDEFINED_178 = 178,//!< LRed beam loop
SND_UNDEFINED_179 = 179,//!< Antifighter beam loop
SND_LIGHTNING_1 = 180,//!< Thunder 1 sound in neblua
SND_LIGHTNING_2 = 181,//!< Thunder 2 sound in neblua
SND_UNDEFINED_182 = 182,//!< 1 sec warm up
SND_UNDEFINED_183 = 183,//!< 1.5 sec warm up
SND_UNDEFINED_184 = 184,//!< 3 sec warm up
SND_UNDEFINED_185 = 185,//!< Shivan Commnode
SND_UNDEFINED_186 = 186,//!< Volition PirateShip
SND_UNDEFINED_187 = 187,//!< SRed warm down
SND_UNDEFINED_188 = 188,//!< LRed warm down
SND_UNDEFINED_189 = 189,//!< AntiFtr warm down
SND_UNDEFINED_190 = 190,//!< Instellation 1
SND_UNDEFINED_191 = 191,//!< Instellation 2
SND_UNDEFINED_192 = 192,//!< (Undefined in Retail)
SND_UNDEFINED_193 = 193,//!< (Undefined in Retail)
SND_UNDEFINED_194 = 194,//!< (Undefined in Retail)
SND_UNDEFINED_195 = 195,//!< (Undefined in Retail)
SND_UNDEFINED_196 = 196,//!< (Undefined in Retail)
SND_UNDEFINED_197 = 197,//!< (Undefined in Retail)
SND_UNDEFINED_198 = 198,//!< (Undefined in Retail)
SND_UNDEFINED_199 = 199,//!< (Undefined in Retail)
COPILOT = 162,//!< copilot (SCP)
UNDEFINED_163 = 163,//!< (Empty in Retail)
UNDEFINED_164 = 164,//!< (Empty in Retail)
UNDEFINED_165 = 165,//!< (Empty in Retail)
UNDEFINED_166 = 166,//!< (Empty in Retail)
UNDEFINED_167 = 167,//!< (Empty in Retail)
UNDEFINED_168 = 168,//!< (Empty in Retail)
UNDEFINED_169 = 169,//!< (Empty in Retail)
UNDEFINED_170 = 170,//!< (Empty in Retail)
UNDEFINED_171 = 171,//!< (Empty in Retail)
UNDEFINED_172 = 172,//!< (Empty in Retail)
SUPERNOVA_1 = 173,//!< SuperNova (distant)
SUPERNOVA_2 = 174,//!< SuperNova (shockwave)
UNDEFINED_175 = 175,//!< Shivan large engine
UNDEFINED_176 = 176,//!< Shivan large engine
UNDEFINED_177 = 177,//!< SRed beam loop
UNDEFINED_178 = 178,//!< LRed beam loop
UNDEFINED_179 = 179,//!< Antifighter beam loop
LIGHTNING_1 = 180,//!< Thunder 1 sound in neblua
LIGHTNING_2 = 181,//!< Thunder 2 sound in neblua
UNDEFINED_182 = 182,//!< 1 sec warm up
UNDEFINED_183 = 183,//!< 1.5 sec warm up
UNDEFINED_184 = 184,//!< 3 sec warm up
UNDEFINED_185 = 185,//!< Shivan Commnode
UNDEFINED_186 = 186,//!< Volition PirateShip
UNDEFINED_187 = 187,//!< SRed warm down
UNDEFINED_188 = 188,//!< LRed warm down
UNDEFINED_189 = 189,//!< AntiFtr warm down
UNDEFINED_190 = 190,//!< Instellation 1
UNDEFINED_191 = 191,//!< Instellation 2
UNDEFINED_192 = 192,//!< (Undefined in Retail)
UNDEFINED_193 = 193,//!< (Undefined in Retail)
UNDEFINED_194 = 194,//!< (Undefined in Retail)
UNDEFINED_195 = 195,//!< (Undefined in Retail)
UNDEFINED_196 = 196,//!< (Undefined in Retail)
UNDEFINED_197 = 197,//!< (Undefined in Retail)
UNDEFINED_198 = 198,//!< (Undefined in Retail)
UNDEFINED_199 = 199,//!< (Undefined in Retail)
SND_BALLISTIC_START_LOAD = 200,//!< (SCP)
SND_BALLISTIC_LOAD = 201,//!< (SCP)
BALLISTIC_START_LOAD = 200,//!< (SCP)
BALLISTIC_LOAD = 201,//!< (SCP)
/**
* Keep this below all defined enum values
*/
MIN_GAME_SOUNDS = 202
MIN_GAME_SOUNDS = 202
};
/**
* Interface sounds
*/
enum InterfaceSoundsIndex {
SND_IFACE_MOUSE_CLICK =0, //!< mouse click
SND_ICON_PICKUP =1, //!< pick up a ship icon (Empty in Retail)
SND_ICON_DROP_ON_WING =2, //!< drop a ship icon on a wing slot
SND_ICON_DROP =3, //!< drop a ship icon back to the list
SND_SCREEN_MODE_PRESSED =4, //!< press briefing, ship selection or weapons bar (top-left)
SND_SWITCH_SCREENS =5, //!< Switching to a new screen, but not commit
SND_HELP_PRESSED =6, //!< help pressed
SND_COMMIT_PRESSED =7, //!< commit pressed
SND_PREV_NEXT_PRESSED =8, //!< prev/next pressed
SND_SCROLL =9, //!< scroll pressed (and scroll)
SND_GENERAL_FAIL =10,//!< general failure sound for any event
SND_SHIP_ICON_CHANGE =11,//!< ship animation starts (ie text and ship first appear)
SND_MAIN_HALL_AMBIENT =12,//!< ambient sound for the Terran main hall (looping)
SND_BTN_SLIDE =13,//!< ambient sound for the Vasudan main hall (looping)
SND_BRIEF_STAGE_CHG =14,//!< brief stage change
SND_BRIEF_STAGE_CHG_FAIL =15,//!< brief stage change fail
SND_BRIEF_ICON_SELECT =16,//!< selet brief icon
SND_USER_OVER =17,//!< user_over (mouse over a control)
SND_USER_SELECT =18,//!< user_click (mouse selects a control)
SND_RESET_PRESSED =19,//!< reset (or similar button) pressed
SND_BRIEF_TEXT_WIPE =20,//!< briefing text wipe
SND_VASUDAN_PA_1 =21,//!< main hall - elevator
SND_WEAPON_ANIM_START =22,//!< weapon animation starts
SND_MAIN_HALL_DOOR_OPEN =23,//!< door in main hall opens
SND_MAIN_HALL_DOOR_CLOSE =24,//!< door in main hall closes
SND_GLOW_OPEN =25,//!< glow in main hall opens
SND_VASUDAN_PA_2 =26,//!< main hall - crane 1
SND_AMBIENT_MENU =27,//!< ambient sound for menus off the main hall (looping)
SND_POPUP_APPEAR =28,//!< popup dialog box appeared
SND_POPUP_DISAPPEAR =29,//!< popup dialog box goes away
SND_VOICE_SLIDER_CLIP =30,//!< voice clip played when volume slider changes
SND_VASUDAN_PA_3 =31,//!< main hall - crane 2
SND_MAIN_HALL_GET_PEPSI =32,//!< main hall options - mouse on
SND_MAIN_HALL_LIFT_UP =33,//!< main hall options - mouse off
SND_MAIN_HALL_WELD1 =34,//!< main hall tech room - mouse on
SND_MAIN_HALL_WELD2 =35,//!< main hall tech room - mouse off
SND_MAIN_HALL_WELD3 =36,//!< main hall exit open
SND_MAIN_HALL_WELD4 =37,//!< main hall exit close
SND_MAIN_HALL_INT1 =38,//!< main hall random intercom 1
SND_MAIN_HALL_INT2 =39,//!< main hall random intercom 2
SND_MAIN_HALL_INT3 =40,//!< main hall random intercom 3
SND_ICON_HIGHLIGHT =41,//!< spinning highlight in briefing
SND_BRIEFING_STATIC =42,//!< static in a briefing stage cut
SND_MAIN_HALL2_CRANE1_1 =43,//!< main hall campaign - mouse on
SND_MAIN_HALL2_CRANE1_2 =44,//!< main hall campaign - mouse off
SND_MAIN_HALL2_CRANE2_1 =45,//!< vasudan hall - hatch open
SND_MAIN_HALL2_CRANE2_2 =46,//!< vasudan hall - hatch close
SND_MAIN_HALL2_CAR1 =47,//!< vasudan hall - roll open
SND_MAIN_HALL2_CAR2 =48,//!< vasudan hall - roll close
SND_MAIN_HALL2_INT1 =49,//!< vasudan hall - lift up
SND_MAIN_HALL2_INT2 =50,//!< vasudan hall - lift down
SND_MAIN_HALL2_INT3 =51,//!< vasudan hall - glow on
SND_INTERFACE_UNDEFINED_52 =52,//!< vasudan hall - glow off
SND_INTERFACE_UNDEFINED_53 =53,//!< vasudan hall - skiff loop
SND_INTERFACE_UNDEFINED_54 =54,//!< vasudan hall - screen on
SND_INTERFACE_UNDEFINED_55 =55,//!< vasudan hall - screen off
SND_INTERFACE_UNDEFINED_56 =56,//!< vasudan hall - vasudan greeting
SND_INTERFACE_UNDEFINED_57 =57,//!< vasudan hall - vasudan bye
SND_INTERFACE_UNDEFINED_58 =58,//!< vasudan hall - vasudan pa 1
SND_INTERFACE_UNDEFINED_59 =59,//!< vasudan hall - vasudan pa 2
SND_INTERFACE_UNDEFINED_60 =60,//!< vasudan hall - vasudan pa 3
SND_VASUDAN_BUP =61,//!< bup bup bup-bup bup bup
SND_INTERFACE_UNDEFINED_62 =62,//!< thankyou
SND_INTERFACE_UNDEFINED_63 =62,//!< vasudan hall - exit open
SND_INTERFACE_UNDEFINED_64 =62,//!< vasudan hall - exit close
enum InterfaceSounds {
IFACE_MOUSE_CLICK =0, //!< mouse click
ICON_PICKUP =1, //!< pick up a ship icon (Empty in Retail)
ICON_DROP_ON_WING =2, //!< drop a ship icon on a wing slot
ICON_DROP =3, //!< drop a ship icon back to the list
SCREEN_MODE_PRESSED =4, //!< press briefing, ship selection or weapons bar (top-left)
SWITCH_SCREENS =5, //!< Switching to a new screen, but not commit
HELP_PRESSED =6, //!< help pressed
COMMIT_PRESSED =7, //!< commit pressed
PREV_NEXT_PRESSED =8, //!< prev/next pressed
SCROLL =9, //!< scroll pressed (and scroll)
GENERAL_FAIL =10,//!< general failure sound for any event
SHIP_ICON_CHANGE =11,//!< ship animation starts (ie text and ship first appear)
MAIN_HALL_AMBIENT =12,//!< ambient sound for the Terran main hall (looping)
BTN_SLIDE =13,//!< ambient sound for the Vasudan main hall (looping)
BRIEF_STAGE_CHG =14,//!< brief stage change
BRIEF_STAGE_CHG_FAIL =15,//!< brief stage change fail
BRIEF_ICON_SELECT =16,//!< selet brief icon
USER_OVER =17,//!< user_over (mouse over a control)
USER_SELECT =18,//!< user_click (mouse selects a control)
RESET_PRESSED =19,//!< reset (or similar button) pressed
BRIEF_TEXT_WIPE =20,//!< briefing text wipe
VASUDAN_PA_1 =21,//!< main hall - elevator
WEAPON_ANIM_START =22,//!< weapon animation starts
MAIN_HALL_DOOR_OPEN =23,//!< door in main hall opens
MAIN_HALL_DOOR_CLOSE =24,//!< door in main hall closes
GLOW_OPEN =25,//!< glow in main hall opens
VASUDAN_PA_2 =26,//!< main hall - crane 1
AMBIENT_MENU =27,//!< ambient sound for menus off the main hall (looping)
POPUP_APPEAR =28,//!< popup dialog box appeared
POPUP_DISAPPEAR =29,//!< popup dialog box goes away
VOICE_SLIDER_CLIP =30,//!< voice clip played when volume slider changes
VASUDAN_PA_3 =31,//!< main hall - crane 2
MAIN_HALL_GET_PEPSI =32,//!< main hall options - mouse on
MAIN_HALL_LIFT_UP =33,//!< main hall options - mouse off
MAIN_HALL_WELD1 =34,//!< main hall tech room - mouse on
MAIN_HALL_WELD2 =35,//!< main hall tech room - mouse off
MAIN_HALL_WELD3 =36,//!< main hall exit open
MAIN_HALL_WELD4 =37,//!< main hall exit close
MAIN_HALL_INT1 =38,//!< main hall random intercom 1
MAIN_HALL_INT2 =39,//!< main hall random intercom 2
MAIN_HALL_INT3 =40,//!< main hall random intercom 3
ICON_HIGHLIGHT =41,//!< spinning highlight in briefing
BRIEFING_STATIC =42,//!< static in a briefing stage cut
MAIN_HALL2_CRANE1_1 =43,//!< main hall campaign - mouse on
MAIN_HALL2_CRANE1_2 =44,//!< main hall campaign - mouse off
MAIN_HALL2_CRANE2_1 =45,//!< vasudan hall - hatch open
MAIN_HALL2_CRANE2_2 =46,//!< vasudan hall - hatch close
MAIN_HALL2_CAR1 =47,//!< vasudan hall - roll open
MAIN_HALL2_CAR2 =48,//!< vasudan hall - roll close
MAIN_HALL2_INT1 =49,//!< vasudan hall - lift up
MAIN_HALL2_INT2 =50,//!< vasudan hall - lift down
MAIN_HALL2_INT3 =51,//!< vasudan hall - glow on
INTERFACE_UNDEFINED_52 =52,//!< vasudan hall - glow off
INTERFACE_UNDEFINED_53 =53,//!< vasudan hall - skiff loop
INTERFACE_UNDEFINED_54 =54,//!< vasudan hall - screen on
INTERFACE_UNDEFINED_55 =55,//!< vasudan hall - screen off
INTERFACE_UNDEFINED_56 =56,//!< vasudan hall - vasudan greeting
INTERFACE_UNDEFINED_57 =57,//!< vasudan hall - vasudan bye
INTERFACE_UNDEFINED_58 =58,//!< vasudan hall - vasudan pa 1
INTERFACE_UNDEFINED_59 =59,//!< vasudan hall - vasudan pa 2
INTERFACE_UNDEFINED_60 =60,//!< vasudan hall - vasudan pa 3
VASUDAN_BUP =61,//!< bup bup bup-bup bup bup
INTERFACE_UNDEFINED_62 =62,//!< thankyou
INTERFACE_UNDEFINED_63 =62,//!< vasudan hall - exit open
INTERFACE_UNDEFINED_64 =62,//!< vasudan hall - exit close
/**
* Keep this below all defined enum values
*/
MIN_INTERFACE_SOUNDS =70 //!< MIN_INTERFACE_SOUNDS
MIN_INTERFACE_SOUNDS =70 //!< MIN_INTERFACE_SOUNDS
};
// These two id types are defined as sublcasses so that type safe implicit conversions are possible from the predefined
// sound enum values
struct gamesnd_id_tag{};
/**
* @brief A game sound handle type
*
* This allows implicit conversions from the GameSounds enum class.
*/
class gamesnd_id : public util::ID<gamesnd_id_tag, int, -1> {
public:
/*implicit*/ gamesnd_id(GameSounds snd) : util::ID<gamesnd_id_tag, int, -1>(static_cast<int>(snd)) {}
explicit gamesnd_id(int val) : ID(val) {
}
gamesnd_id() {
}
};
struct interface_snd_tag{};
/**
* @brief A interface sound handle type
*
* This allows implicit conversions from the InterfaceSounds enum class.
*/
class interface_snd_id : public util::ID<interface_snd_tag, int, -1> {
public:
/*implicit*/ interface_snd_id(InterfaceSounds snd) : util::ID<interface_snd_tag, int, -1>(static_cast<int>(snd)) {}
interface_snd_id() {
}
explicit interface_snd_id(int val) : ID(val) {
}
};
void gamesnd_parse_soundstbl(); // Loads in general game sounds from sounds.tbl
void gamesnd_close(); // close out gamesnd... only call from game_shutdown()!
void gamesnd_load_gameplay_sounds();
void gamesnd_unload_gameplay_sounds();
void gamesnd_load_interface_sounds();
void gamesnd_unload_interface_sounds();
void gamesnd_preload_common_sounds();
void gamesnd_load_gameplay_sounds();
void gamesnd_unload_gameplay_sounds();
void gamesnd_play_iface(interface_snd_id n);
void gamesnd_play_error_beep();
gamesnd_id gamesnd_get_by_name(const char* name);
interface_snd_id gamesnd_get_by_iface_name(const char* name);
gamesnd_id gamesnd_get_by_tbl_index(int index);
interface_snd_id gamesnd_get_by_iface_tbl_index(int index);
//This should handle NO_SOUND just fine since it doesn't directly access lowlevel code
//Does all parsing for a sound
void parse_game_sound(const char* tag, gamesnd_id* idx_dest);
void parse_iface_sound(const char* tag, interface_snd_id* idx_dest);
void parse_iface_sound_list(const char* tag, SCP_vector<interface_snd_id>& destination, const char* object_name, bool scp_list = false);
// this is a callback, so it needs to be a real function
void common_play_highlight_sound();
/**
* @brief Gets a pointer to the game sound with the specified handle
* @param handle The sound handle
* @return The game sound handle
*/
game_snd* gamesnd_get_game_sound(int handle);
game_snd* gamesnd_get_game_sound(gamesnd_id handle);
/**
* @brief Gets a pointer to the interface sound with the specified handle
* @param handle The sound handle
* @return The interface sound handle
*/
game_snd* gamesnd_get_interface_sound(int handle);
game_snd* gamesnd_get_interface_sound(interface_snd_id handle);
/**
* @brief Checks if the given sound handle is a valid game sound handle
* @param sound The handle to check
* @return @c true if the handle is valid
*/
bool gamesnd_game_sound_valid(int sound);
bool gamesnd_game_sound_valid(gamesnd_id sound);
/**
* @brief Checks if the given sound handle is a valid interface sound handle
* @param sound The handle to check
* @return @c true if the handle is valid
*/
bool gamesnd_interface_sound_valid(int sound);
bool gamesnd_interface_sound_valid(interface_snd_id sound);
/**
* @brief Determines the maximum time this game sound may take to be played.
+2 -2
View File
@@ -467,7 +467,7 @@ void parse_everything_else(const char *filename)
// We have a string; it should be the name of a color to use.
stuff_string(temp, F_NAME);
for (j = 0; j < TOTAL_COLORS; j++) {
if (!temp.compare(COLOR_NAMES[j])) {
if (temp == COLOR_NAMES[j]) {
break;
}
}
@@ -549,7 +549,7 @@ void parse_everything_else(const char *filename)
// We have a string; it should be the name of a color to use.
stuff_string(temp, F_NAME);
for (j = 0; j < TOTAL_COLORS; j++) {
if (!temp.compare(COLOR_NAMES[j])) {
if (temp == COLOR_NAMES[j]) {
break;
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include <stddef.h>
#include <cstddef>
#include <cstdlib>
#include "globalincs/pstypes.h"
+10 -18
View File
@@ -19,10 +19,10 @@
#include "globalincs/toolchain.h"
#include "utils/strings.h"
#include <stdio.h> // For NULL, etc
#include <stdlib.h>
#include <cstdio> // For NULL, etc
#include <cstdlib>
#include <memory.h>
#include <string.h>
#include <cstring>
#include <algorithm>
#include <cstdint>
@@ -261,14 +261,14 @@ extern int Global_error_count;
// Disabling this functionality is dangerous, crazy values can run rampent unchecked and the longer its disabled
// the more likely you are to have problems getting it working again.
#if defined(NDEBUG)
# define Assert(expr) do { ASSUME(expr); } while (0)
# define Assert(expr) do { ASSUME(expr); } while (false)
#else
# define Assert(expr) do {\
if (!(expr)) {\
os::dialogs::AssertMessage(#expr,__FILE__,__LINE__);\
}\
ASSUME( expr );\
} while (0)
} while (false)
#endif
/*******************NEVER COMMENT Assert ************************************************/
@@ -434,7 +434,7 @@ public:
// - is not "none"
// - is not "<none>"
inline bool VALID_FNAME(const char* x) {
return strlen((x)) && stricmp((x), "none") && stricmp((x), "<none>");
return strlen((x)) && stricmp((x), "none") != 0 && stricmp((x), "<none>") != 0;
}
/**
* @brief Checks if the specified string may be a valid file name
@@ -462,9 +462,8 @@ inline bool VALID_FNAME(const SCP_string& x) {
SCP_string dump_stacktrace();
// DEBUG compile time catch for dangerous uses of memset/memcpy/memmove
// would prefer std::is_trivially_copyable but it's not supported by gcc yet
// ref: http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html
#if !defined(NDEBUG) && !defined(USING_THIRD_PARTY_LIBS)
// This is disabled for VS2013 and lower since that doesn't support the necessary features
#if !defined(NDEBUG) && !defined(USING_THIRD_PARTY_LIBS) && (!defined(_MSC_VER) || _MSC_VER >= 1900)
#if SCP_COMPILER_CXX_AUTO_TYPE && SCP_COMPILER_CXX_STATIC_ASSERT && defined(HAVE_STD_IS_TRIVIALLY_COPYABLE)
// feature support seems to be: gcc clang msvc
// auto 4.4 2.9 2010
@@ -480,15 +479,8 @@ SCP_string dump_stacktrace();
// Put into std to be compatible with code that uses std::mem*
namespace std
{
// This is a separate check which also checks if arrays are trivially copyable since Visual Studio 2013 thinks they are not
#if SCP_COMPILER_IS_MSVC && _MSC_VER <= 1800
template<typename T>
using trivial_check = std::is_trivial<T>;
#else
template<typename T>
using trivial_check = std::is_trivially_copyable<T>;
#endif
template<typename T>
using trivial_check = std::is_trivially_copyable<T>;
template<typename T>
void *memset_if_trivial_else_error(T *memset_data, int ch, size_t count)
+2 -2
View File
@@ -20,8 +20,8 @@
*/
/* errno_t, EINVAL, ERANGE, etc.. */
#include <errno.h>
#include <stdlib.h> /* size_t */
#include <cerrno>
#include <cstdlib> /* size_t */
/* Because errno_t is not (yet) standard, we define it here like this */
typedef int errno_t;
+1 -1
View File
@@ -13,7 +13,7 @@
#define _SYSTEMVARS_H
#include "globalincs/pstypes.h"
#include "math.h"
#include <cmath>
#include <cstdint>
+10 -4
View File
@@ -32,7 +32,7 @@
#define ASSUME(x)
#if defined(NDEBUG)
# define Assertion(expr, msg, ...) do { } while (0)
# define Assertion(expr, msg, ...) do { } while (false)
#else
/*
* NOTE: Assertion() can only use its proper functionality in compilers
@@ -43,7 +43,7 @@
if (!(expr)) { \
os::dialogs::AssertMessage(#expr, __FILE__, __LINE__, msg, ##__VA_ARGS__); \
} \
} while (0)
} while (false)
#endif
/* C++11 Standard Detection */
@@ -61,8 +61,6 @@
#define SIZE_T_ARG "%zu"
#define PTRDIFF_T_ARG "%zd"
#define NOEXCEPT noexcept
#define likely(x) __builtin_expect((long) !!(x), 1L)
#define unlikely(x) __builtin_expect((long) !!(x), 0L)
@@ -75,3 +73,11 @@
#else
#define FALLTHROUGH
#endif
#ifndef CLANG_ANALYZER_NORETURN
#if __has_feature(attribute_analyzer_noreturn)
#define CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
#else
#define CLANG_ANALYZER_NORETURN
#endif
#endif
+5
View File
@@ -58,3 +58,8 @@
* Some compilers issue a warning if a fallthrough is detected. This define can be used to suppress that warning.
*/
#define FALLTHROUGH
/**
* @brief Specifies that an analyzer should consider this function as no-return
*/
#define CLANG_ANALYZER_NORETURN
+4 -4
View File
@@ -32,7 +32,7 @@
#define ASSUME(x)
#if defined(NDEBUG)
# define Assertion(expr, msg, ...) do {} while (0)
# define Assertion(expr, msg, ...) do {} while (false)
#else
/*
* NOTE: Assertion() can only use its proper functionality in compilers
@@ -43,7 +43,7 @@
if (!(expr)) { \
os::dialogs::AssertMessage(#expr, __FILE__, __LINE__, msg, ##__VA_ARGS__); \
} \
} while (0)
} while (false)
#endif
/* C++11 Standard Detection */
@@ -60,8 +60,6 @@
#define SIZE_T_ARG "%zu"
#define PTRDIFF_T_ARG "%zd"
#define NOEXCEPT noexcept
#define likely(x) __builtin_expect((long) !!(x), 1L)
#define unlikely(x) __builtin_expect((long) !!(x), 0L)
@@ -72,3 +70,5 @@
#else
#define FALLTHROUGH
#endif
#define CLANG_ANALYZER_NORETURN
+8 -8
View File
@@ -17,8 +17,10 @@
* the detected toolchain.
*/
#include <stdio.h>
#define SCP_FORMAT_STRING
#define SCP_FORMAT_STRING_ARGS(x,y) __attribute__((format(printf, x, y)))
#define SCP_FORMAT_STRING_ARGS(x,y) __attribute__((format(__MINGW_PRINTF_FORMAT, x, y)))
#define __UNUSED __attribute__((__unused__))
#define __ALIGNED(x) __attribute__((__aligned__(x)))
@@ -32,7 +34,7 @@
#define ASSUME(x)
#if defined(NDEBUG)
# define Assertion(expr, msg, ...) do {} while (0)
# define Assertion(expr, msg, ...) do {} while (false)
#else
/*
* NOTE: Assertion() can only use its proper functionality in compilers
@@ -43,7 +45,7 @@
if (!(expr)) { \
os::dialogs::AssertMessage(#expr, __FILE__, __LINE__, msg, ##__VA_ARGS__); \
} \
} while (0)
} while (false)
#endif
/* C++11 Standard Detection */
@@ -55,17 +57,15 @@
#define SIZE_T_ARG "%zu"
#define PTRDIFF_T_ARG "%zd"
#define NOEXCEPT noexcept
#define likely(x) __builtin_expect((long) !!(x), 1L)
#define unlikely(x) __builtin_expect((long) !!(x), 0L)
#define __STDC_FORMAT_MACROS 1
#define USED_VARIABLE __attribute__((used))
#if SCP_COMPILER_VERSION_MAJOR >= 7
#define FALLTHROUGH [[fallthough]]
#define FALLTHROUGH __attribute__((fallthrough))
#else
#define FALLTHROUGH
#endif
#define CLANG_ANALYZER_NORETURN
+8 -13
View File
@@ -38,9 +38,9 @@
#if defined(NDEBUG)
# if _MSC_VER >= 1400 /* MSVC 2005 or newer */
# define Assertion(expr, msg, ...) do { ASSUME(expr); } while (0)
# define Assertion(expr, msg, ...) do { ASSUME(expr); } while (false)
# else
# define Assertion(expr, msg) do {} while (0)
# define Assertion(expr, msg) do {} while (false)
# endif
#else
/*
@@ -53,13 +53,13 @@
if (!(expr)) { \
os::dialogs::AssertMessage(#expr, __FILE__, __LINE__, msg, __VA_ARGS__); \
} \
} while (0)
} while (false)
# else /* Older MSVC compilers */
# define Assertion(expr, msg) \
do { \
if (!(expr)) { \
os::dialogs::AssertMessage(#expr, __FILE__, __LINE__); \
} while (0)
} while (false)
# endif
#endif
@@ -71,15 +71,8 @@
# endif
#endif
#define PTRDIFF_T_ARG "%Iu"
#define SIZE_T_ARG "%Id"
/* The 'noexcept' keyword is not defined in versions before VS 2015. */
#if _MSC_VER < 1900
# define NOEXCEPT
#else
# define NOEXCEPT noexcept
#endif
#define SIZE_T_ARG "%Iu"
#define PTRDIFF_T_ARG "%Id"
#define likely(x)
#define unlikely(x)
@@ -87,3 +80,5 @@
#define USED_VARIABLE
#define FALLTHROUGH
#define CLANG_ANALYZER_NORETURN
+3 -6
View File
@@ -14,7 +14,7 @@
#include <windowsx.h>
#endif
#include <limits.h>
#include <climits>
#include <algorithm>
#include "cmdline/cmdline.h"
@@ -693,7 +693,7 @@ DCF(clear_color, "set clear color r, g, b")
gr_set_clear_color(r, g, b);
}
void gr_set_palette_internal( const char *name, ubyte * palette, int restrict_font_to_128 )
void gr_set_palette_internal( const char * /*name*/, ubyte * palette, int /*restrict_font_to_128*/ )
{
if ( palette == NULL ) {
// Create a default palette
@@ -1125,9 +1125,6 @@ bool gr_init(std::unique_ptr<os::GraphicsOperations>&& graphicsOps, int d_mode,
gpu_heap_init();
mprintf(("Checking graphics capabilities:\n"));
mprintf((" Bindless texturing: %s\n", gr_is_capable(CAPABILITY_BINDLESS_TEXTURING) ? "Enabled" : "Disabled"));
bool missing_installation = false;
if (!running_unittests && Web_cursor == nullptr) {
if (Is_standalone) {
@@ -2034,7 +2031,7 @@ void poly_list::make_index_buffer(SCP_vector<int> &vertex_list)
(*this) = buffer_list_internal;
}
poly_list& poly_list::operator = (poly_list &other_list)
poly_list& poly_list::operator = (const poly_list &other_list)
{
allocate(other_list.n_verts);
+8 -15
View File
@@ -286,7 +286,6 @@ typedef enum gr_capability {
CAPABILITY_POINT_PARTICLES,
CAPABILITY_TIMESTAMP_QUERY,
CAPABILITY_SEPARATE_BLEND_FUNCTIONS,
CAPABILITY_BINDLESS_TEXTURING, //!< This is the ability to encode textures in uniform buffers
} gr_capability;
enum class gr_property {
@@ -366,7 +365,7 @@ class poly_list {
public:
poly_list(): n_verts(0), vert(NULL), norm(NULL), tsb(NULL), submodels(NULL), sorted_indices(NULL), currently_allocated(0) {}
~poly_list();
poly_list& operator = (poly_list&);
poly_list& operator=(const poly_list&);
void allocate(int size);
void make_index_buffer(SCP_vector<int> &vertex_list);
@@ -710,14 +709,14 @@ typedef struct screen {
void (*gf_set_clear_color)(int r, int g, int b);
// Here be the bitmap functions
void (*gf_bm_free_data)(int n, bool release);
void (*gf_bm_create)(int n);
void (*gf_bm_init)(int n);
void (*gf_bm_free_data)(bitmap_slot* slot, bool release);
void (*gf_bm_create)(bitmap_slot* slot);
void (*gf_bm_init)(bitmap_slot* slot);
void (*gf_bm_page_in_start)();
bool (*gf_bm_data)(int n, bitmap* bm);
bool (*gf_bm_data)(int handle, bitmap* bm);
int (*gf_bm_make_render_target)(int n, int *width, int *height, int *bpp, int *mm_lvl, int flags );
int (*gf_bm_set_render_target)(int n, int face);
int (*gf_bm_make_render_target)(int handle, int *width, int *height, int *bpp, int *mm_lvl, int flags );
int (*gf_bm_set_render_target)(int handle, int face);
void (*gf_translate_texture_matrix)(int unit, const vec3d *shift);
void (*gf_push_texture_matrix)(int unit);
@@ -758,7 +757,7 @@ typedef struct screen {
void (*gf_sphere)(material *material_def, float rad);
int (*gf_maybe_create_shader)(shader_type type, unsigned int flags);
void (*gf_recompile_all_shaders)(std::function<void(size_t, size_t)>progress_callback);
void (*gf_recompile_all_shaders)(const std::function<void(size_t, size_t)>& progress_callback);
void (*gf_clear_states)();
@@ -804,8 +803,6 @@ typedef struct screen {
void (*gf_sync_delete)(gr_sync sync);
void (*gf_set_viewport)(int x, int y, int width, int height);
uint64_t (*gf_get_texture_handle)(int bitmap_handle, int bitmap_type);
} screen;
// handy macro
@@ -1111,10 +1108,6 @@ inline void gr_sync_delete(gr_sync sync) {
(*gr_screen.gf_sync_delete)(sync);
}
inline uint64_t gr_get_texture_handle(int bitmap, int bitmap_type) {
return (*gr_screen.gf_get_texture_handle)(bitmap, bitmap_type);
}
// color functions
void gr_get_color( int *r, int *g, int b );
void gr_init_color(color *c, int r, int g, int b);
+1 -1
View File
@@ -172,7 +172,7 @@ void decal_draw_list::render() {
void decal_draw_list::add_decal(int diffuse_bitmap,
int glow_bitmap,
int normal_bitmap,
float decal_timer,
float /*decal_timer*/,
const matrix4& transform,
float base_alpha) {
if (!check_box_in_view(transform)) {
+4 -4
View File
@@ -137,7 +137,7 @@ void geometry_batcher::clone(const geometry_batcher &geo)
}
}
const geometry_batcher &geometry_batcher::operator=(const geometry_batcher &geo)
geometry_batcher& geometry_batcher::operator=(const geometry_batcher &geo)
{
if (this != &geo) {
clone(geo);
@@ -522,7 +522,7 @@ float geometry_batcher::draw_laser(vec3d *p0, float width1, vec3d *p1, float wid
return center.xyz.z;
}
void geometry_batcher::render(int flags, float radius)
void geometry_batcher::render(int /*flags*/, float /*radius*/)
{
}
@@ -553,12 +553,12 @@ void geometry_batcher::load_buffer(effect_vertex* buffer, int *n_verts)
*n_verts = *n_verts + verts_to_render;
}
void geometry_batcher::render_buffer(int buffer_handle, int flags)
void geometry_batcher::render_buffer(int /*buffer_handle*/, int /*flags*/)
{
}
void geometry_shader_batcher::render_buffer(int buffer_handle, int flags)
void geometry_shader_batcher::render_buffer(int /*buffer_handle*/, int /*flags*/)
{
}
+1 -3
View File
@@ -31,7 +31,7 @@ public:
~geometry_batcher();
geometry_batcher(const geometry_batcher &geo) { clone(geo); }
const geometry_batcher &operator=(const geometry_batcher &geo);
geometry_batcher& operator=(const geometry_batcher &geo);
// initial memory space needed
// NOTE: This MUST be called BEFORE calling any of the draw_*() functions!!
@@ -68,8 +68,6 @@ public:
// determine if we even need to try and render this (helpful for particle system)
int need_to_render() { return n_to_render; }
void operator =(int){}
};
class geometry_shader_batcher
+64 -70
View File
@@ -28,12 +28,12 @@ int gr_stub_create_buffer(BufferType, BufferUsageHint)
return -1;
}
void gr_stub_delete_buffer(int handle)
void gr_stub_delete_buffer(int /*handle*/)
{
}
int gr_stub_preload(int bitmap_num, int is_aabitmap)
int gr_stub_preload(int /*bitmap_num*/, int /*is_aabitmap*/)
{
return 0;
}
@@ -48,21 +48,21 @@ int gr_stub_zbuffer_get()
return 0;
}
int gr_stub_zbuffer_set(int mode)
int gr_stub_zbuffer_set(int /*mode*/)
{
return 0;
}
void gr_set_fill_mode_stub(int mode)
void gr_set_fill_mode_stub(int /*mode*/)
{
}
void gr_stub_activate(int active)
void gr_stub_activate(int /*active*/)
{
}
void gr_stub_cleanup(int minimize)
void gr_stub_cleanup(int /*minimize*/)
{
}
@@ -74,19 +74,19 @@ void gr_stub_flip()
{
}
void gr_stub_fog_set(int fog_mode, int r, int g, int b, float fog_near, float fog_far)
void gr_stub_fog_set(int /*fog_mode*/, int /*r*/, int /*g*/, int /*b*/, float /*fog_near*/, float /*fog_far*/)
{
}
void gr_stub_free_screen(int id)
void gr_stub_free_screen(int /*id*/)
{
}
void gr_stub_get_region(int front, int w, int h, ubyte *data)
void gr_stub_get_region(int /*front*/, int /*w*/, int /*h*/, ubyte * /*data*/)
{
}
void gr_stub_pop_texture_matrix(int unit)
void gr_stub_pop_texture_matrix(int /*unit*/)
{
}
@@ -94,15 +94,15 @@ void gr_stub_preload_init()
{
}
void gr_stub_print_screen(const char *filename)
void gr_stub_print_screen(const char * /*filename*/)
{
}
void gr_stub_push_texture_matrix(int unit)
void gr_stub_push_texture_matrix(int /*unit*/)
{
}
void gr_stub_rect(int x, int y, int w, int h, int resize_mode)
void gr_stub_rect(int /*x*/, int /*y*/, int /*w*/, int /*h*/, int /*resize_mode*/)
{
}
@@ -110,78 +110,78 @@ void gr_stub_reset_clip()
{
}
void gr_stub_restore_screen(int id)
void gr_stub_restore_screen(int /*id*/)
{
}
void gr_stub_save_mouse_area(int x, int y, int w, int h)
void gr_stub_save_mouse_area(int /*x*/, int /*y*/, int /*w*/, int /*h*/)
{
}
void gr_stub_update_buffer_data(int handle, size_t size, void* data)
void gr_stub_update_buffer_data(int /*handle*/, size_t /*size*/, void* /*data*/)
{
}
void gr_stub_update_buffer_data_offset(int handle, size_t offset, size_t size, void* data)
void gr_stub_update_buffer_data_offset(int /*handle*/, size_t /*offset*/, size_t /*size*/, void* /*data*/)
{
}
void gr_stub_update_transform_buffer(void* data, size_t size)
void gr_stub_update_transform_buffer(void* /*data*/, size_t /*size*/)
{
}
void gr_stub_set_clear_color(int r, int g, int b)
void gr_stub_set_clear_color(int /*r*/, int /*g*/, int /*b*/)
{
}
void gr_stub_set_clip(int x, int y, int w, int h, int resize_mode)
void gr_stub_set_clip(int /*x*/, int /*y*/, int /*w*/, int /*h*/, int /*resize_mode*/)
{
}
int gr_stub_set_cull(int cull)
int gr_stub_set_cull(int /*cull*/)
{
return 0;
}
int gr_stub_set_color_buffer(int mode)
int gr_stub_set_color_buffer(int /*mode*/)
{
return 0;
}
void gr_stub_set_gamma(float gamma)
void gr_stub_set_gamma(float /*gamma*/)
{
}
void gr_stub_set_tex_env_scale(float scale)
void gr_stub_set_tex_env_scale(float /*scale*/)
{
}
void gr_stub_set_texture_addressing(int mode)
void gr_stub_set_texture_addressing(int /*mode*/)
{
}
void gr_stub_stuff_fog_coord(vertex *v)
void gr_stub_stuff_fog_coord(vertex * /*v*/)
{
}
void gr_stub_stuff_secondary_color(vertex *v, ubyte fr, ubyte fg, ubyte fb)
void gr_stub_stuff_secondary_color(vertex * /*v*/, ubyte /*fr*/, ubyte /*fg*/, ubyte /*fb*/)
{
}
void gr_stub_translate_texture_matrix(int unit, const vec3d *shift)
void gr_stub_translate_texture_matrix(int /*unit*/, const vec3d * /*shift*/)
{
}
void gr_stub_zbias_stub(int bias)
void gr_stub_zbias_stub(int /*bias*/)
{
}
void gr_stub_zbuffer_clear(int mode)
void gr_stub_zbuffer_clear(int /*mode*/)
{
}
int gr_stub_stencil_set(int mode)
int gr_stub_stencil_set(int /*mode*/)
{
return 0;
}
@@ -190,7 +190,7 @@ void gr_stub_stencil_clear()
{
}
int gr_stub_alpha_mask_set(int mode, float alpha)
int gr_stub_alpha_mask_set(int /*mode*/, float /*alpha*/)
{
return 0;
}
@@ -199,7 +199,7 @@ int gr_stub_alpha_mask_set(int mode, float alpha)
{
}*/
void gr_stub_post_process_set_effect(const char *name, int x, const vec3d *rgb)
void gr_stub_post_process_set_effect(const char * /*name*/, int /*x*/, const vec3d * /*rgb*/)
{
}
@@ -247,11 +247,11 @@ void gr_stub_deferred_lighting_finish()
{
}
void gr_stub_set_line_width(float width)
void gr_stub_set_line_width(float /*width*/)
{
}
void gr_stub_draw_sphere(material *material_def, float rad)
void gr_stub_draw_sphere(material * /*material_def*/, float /*rad*/)
{
}
@@ -259,34 +259,34 @@ void gr_stub_clear_states()
{
}
void gr_stub_update_texture(int bitmap_handle, int bpp, const ubyte *data, int width, int height)
void gr_stub_update_texture(int /*bitmap_handle*/, int /*bpp*/, const ubyte * /*data*/, int /*width*/, int /*height*/)
{
}
void gr_stub_get_bitmap_from_texture(void* data_out, int bitmap_num)
void gr_stub_get_bitmap_from_texture(void* /*data_out*/, int /*bitmap_num*/)
{
}
int gr_stub_bm_make_render_target(int n, int *width, int *height, int *bpp, int *mm_lvl, int flags)
int gr_stub_bm_make_render_target(int /*n*/, int * /*width*/, int * /*height*/, int * /*bpp*/, int * /*mm_lvl*/, int /*flags*/)
{
return 0;
}
int gr_stub_bm_set_render_target(int n, int face)
int gr_stub_bm_set_render_target(int /*n*/, int /*face*/)
{
return 0;
}
void gr_stub_bm_create(int n)
void gr_stub_bm_create(bitmap_slot* /*slot*/)
{
}
void gr_stub_bm_free_data(int n, bool release)
void gr_stub_bm_free_data(bitmap_slot* /*slot*/, bool /*release*/)
{
}
void gr_stub_bm_init(int n)
void gr_stub_bm_init(bitmap_slot* /*slot*/)
{
}
@@ -294,16 +294,16 @@ void gr_stub_bm_page_in_start()
{
}
bool gr_stub_bm_data(int n, bitmap* bm)
bool gr_stub_bm_data(int /*n*/, bitmap* /*bm*/)
{
return true;
}
int gr_stub_maybe_create_shader(shader_type shader_t, unsigned int flags) {
int gr_stub_maybe_create_shader(shader_type /*shader_t*/, unsigned int /*flags*/) {
return -1;
}
void gr_stub_shadow_map_start(matrix4 *shadow_view_matrix, const matrix* light_matrix)
void gr_stub_shadow_map_start(matrix4 * /*shadow_view_matrix*/, const matrix* /*light_matrix*/)
{
}
@@ -311,47 +311,47 @@ void gr_stub_shadow_map_end()
{
}
void gr_stub_render_shield_impact(shield_material *material_info, primitive_type prim_type, vertex_layout *layout, int buffer_handle, int n_verts)
void gr_stub_render_shield_impact(shield_material * /*material_info*/, primitive_type /*prim_type*/, vertex_layout * /*layout*/, int /*buffer_handle*/, int /*n_verts*/)
{
}
void gr_stub_render_model(model_material* material_info, indexed_vertex_source *vert_source, vertex_buffer* bufferp, size_t texi)
void gr_stub_render_model(model_material* /*material_info*/, indexed_vertex_source * /*vert_source*/, vertex_buffer* /*bufferp*/, size_t /*texi*/)
{
}
void gr_stub_render_primitives(material* material_info, primitive_type prim_type, vertex_layout* layout, int offset, int n_verts, int buffer_handle, size_t buffer_offset)
void gr_stub_render_primitives(material* /*material_info*/, primitive_type /*prim_type*/, vertex_layout* /*layout*/, int /*offset*/, int /*n_verts*/, int /*buffer_handle*/, size_t /*buffer_offset*/)
{
}
void gr_stub_render_primitives_particle(particle_material* material_info, primitive_type prim_type, vertex_layout* layout, int offset, int n_verts, int buffer_handle)
void gr_stub_render_primitives_particle(particle_material* /*material_info*/, primitive_type /*prim_type*/, vertex_layout* /*layout*/, int /*offset*/, int /*n_verts*/, int /*buffer_handle*/)
{
}
void gr_stub_render_primitives_distortion(distortion_material* material_info, primitive_type prim_type, vertex_layout* layout, int offset, int n_verts, int buffer_handle)
void gr_stub_render_primitives_distortion(distortion_material* /*material_info*/, primitive_type /*prim_type*/, vertex_layout* /*layout*/, int /*offset*/, int /*n_verts*/, int /*buffer_handle*/)
{
}
void gr_stub_render_movie(movie_material* material_info, primitive_type prim_type, vertex_layout* layout, int n_verts, int buffer)
void gr_stub_render_movie(movie_material* /*material_info*/, primitive_type /*prim_type*/, vertex_layout* /*layout*/, int /*n_verts*/, int /*buffer*/)
{
}
void gr_stub_render_nanovg(nanovg_material* material_info,
primitive_type prim_type,
vertex_layout* layout,
int offset,
int n_verts,
int buffer_handle) {
void gr_stub_render_nanovg(nanovg_material* /*material_info*/,
primitive_type /*prim_type*/,
vertex_layout* /*layout*/,
int /*offset*/,
int /*n_verts*/,
int /*buffer_handle*/) {
}
void gr_stub_render_primitives_batched(batched_bitmap_material* material_info, primitive_type prim_type, vertex_layout* layout, int offset, int n_verts, int buffer_handle)
void gr_stub_render_primitives_batched(batched_bitmap_material* /*material_info*/, primitive_type /*prim_type*/, vertex_layout* /*layout*/, int /*offset*/, int /*n_verts*/, int /*buffer_handle*/)
{
}
bool gr_stub_is_capable(gr_capability capability)
bool gr_stub_is_capable(gr_capability /*capability*/)
{
return false;
}
@@ -367,28 +367,24 @@ int gr_stub_create_query_object()
return -1;
}
void gr_stub_query_value(int obj, QueryType type)
void gr_stub_query_value(int /*obj*/, QueryType /*type*/)
{
}
bool gr_stub_query_value_available(int obj)
bool gr_stub_query_value_available(int /*obj*/)
{
return false;
}
std::uint64_t gr_stub_get_query_value(int obj)
std::uint64_t gr_stub_get_query_value(int /*obj*/)
{
return 0;
}
void gr_stub_delete_query_object(int obj)
void gr_stub_delete_query_object(int /*obj*/)
{
}
uint64_t gr_stub_get_texture_handle(int bitmap_handle, int bitmap_type) {
return 0;
}
bool gr_stub_init()
{
if (gr_screen.res != GR_640) {
@@ -528,7 +524,7 @@ bool gr_stub_init()
gr_screen.gf_get_query_value = gr_stub_get_query_value;
gr_screen.gf_delete_query_object = gr_stub_delete_query_object;
gr_screen.gf_create_viewport = [](const os::ViewPortProperties& props) {
gr_screen.gf_create_viewport = [](const os::ViewPortProperties&) {
return std::unique_ptr<os::Viewport>();
};
gr_screen.gf_use_viewport = [](os::Viewport*) {
@@ -536,7 +532,5 @@ bool gr_stub_init()
gr_screen.gf_bind_uniform_buffer = [](uniform_block_type, size_t, size_t, int) {};
gr_screen.gf_get_texture_handle = gr_stub_get_texture_handle;
return true;
}
+1 -1
View File
@@ -293,7 +293,7 @@ void gr_light_init() {
gr_lights.reserve(1024);
}
void gr_set_lighting(bool set, bool state) {
void gr_set_lighting(bool /*set*/, bool state) {
if (!state) {
return;
}
+1 -1
View File
@@ -254,7 +254,7 @@ public:
void set_batching(bool enabled);
bool is_batched() const;
virtual uint get_shader_flags() const override;
uint get_shader_flags() const override;
void set_fog(int r, int g, int b, float near, float far);
void set_fog();
+2 -2
View File
@@ -157,11 +157,11 @@ opengl::ShaderProgram::~ShaderProgram() {
}
}
opengl::ShaderProgram::ShaderProgram(ShaderProgram&& other): _program_id(0), Uniforms(this) {
opengl::ShaderProgram::ShaderProgram(ShaderProgram&& other) SCP_NOEXCEPT : _program_id(0), Uniforms(this) {
*this = std::move(other);
}
opengl::ShaderProgram& opengl::ShaderProgram::operator=(ShaderProgram&& other) {
opengl::ShaderProgram& opengl::ShaderProgram::operator=(ShaderProgram&& other) SCP_NOEXCEPT {
std::swap(_program_id, other._program_id);
std::swap(Uniforms, other.Uniforms);
+2 -2
View File
@@ -91,8 +91,8 @@ class ShaderProgram {
ShaderProgram(const ShaderProgram&) SCP_DELETED_FUNCTION;
ShaderProgram& operator=(const ShaderProgram&) SCP_DELETED_FUNCTION;
ShaderProgram(ShaderProgram&& other);
ShaderProgram& operator=(ShaderProgram&& other);
ShaderProgram(ShaderProgram&& other) SCP_NOEXCEPT;
ShaderProgram& operator=(ShaderProgram&& other) SCP_NOEXCEPT;
void use();
+6 -10
View File
@@ -382,7 +382,7 @@ void gr_opengl_shutdown()
GL_context = nullptr;
}
void gr_opengl_cleanup(bool closing, int minimize)
void gr_opengl_cleanup(bool closing, int /*minimize*/)
{
if ( !GL_initted ) {
return;
@@ -619,7 +619,7 @@ void gr_opengl_set_gamma(float gamma)
}
}
void gr_opengl_get_region(int front, int w, int h, ubyte *data)
void gr_opengl_get_region(int /*front*/, int w, int h, ubyte *data)
{
// if (front) {
@@ -807,17 +807,17 @@ void gr_opengl_zbias(int bias)
}
}
void gr_opengl_push_texture_matrix(int unit)
void gr_opengl_push_texture_matrix(int /*unit*/)
{
}
void gr_opengl_pop_texture_matrix(int unit)
void gr_opengl_pop_texture_matrix(int /*unit*/)
{
}
void gr_opengl_translate_texture_matrix(int unit, const vec3d *shift)
void gr_opengl_translate_texture_matrix(int /*unit*/, const vec3d * /*shift*/)
{
}
@@ -1194,8 +1194,6 @@ void opengl_setup_function_pointers()
gr_screen.gf_set_viewport = gr_opengl_set_viewport;
gr_screen.gf_get_texture_handle = gr_opengl_get_texture_handle;
// NOTE: All function pointers here should have a Cmdline_nohtl check at the top
// if they shouldn't be run in non-HTL mode, Don't keep separate entries.
// *****************************************************************************
@@ -1203,7 +1201,7 @@ void opengl_setup_function_pointers()
#ifndef NDEBUG
static void APIENTRY debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const GLchar *message, const void *userParam) {
GLsizei /*length*/, const GLchar *message, const void * /*userParam*/) {
if (source == GL_DEBUG_SOURCE_APPLICATION_ARB) {
// Ignore application messages
return;
@@ -1583,8 +1581,6 @@ bool gr_opengl_is_capable(gr_capability capability)
return GLAD_GL_ARB_timer_query != 0; // Timestamp queries are available from 3.3 onwards
case CAPABILITY_SEPARATE_BLEND_FUNCTIONS:
return GLAD_GL_ARB_draw_buffers_blend != 0; // We need an OpenGL extension for this
case CAPABILITY_BINDLESS_TEXTURING:
return GLAD_GL_ARB_bindless_texture != 0 && !Cmdline_no_bindless_textures;
}
return false;
+15 -24
View File
@@ -51,31 +51,28 @@ int get_num_mipmap_levels(int w, int h)
/**
* Anything API specific to freeing bm data
*/
void gr_opengl_bm_free_data(int n, bool release)
void gr_opengl_bm_free_data(bitmap_slot* slot, bool release)
{
Assert( (n >= 0) && (n < MAX_BITMAPS) );
if ( release )
opengl_free_texture_slot( n );
opengl_free_texture_slot( slot );
if ( (bm_bitmaps[n].type == BM_TYPE_RENDER_TARGET_STATIC) || (bm_bitmaps[n].type == BM_TYPE_RENDER_TARGET_DYNAMIC) )
opengl_kill_render_target( n );
if ( (slot->entry.type == BM_TYPE_RENDER_TARGET_STATIC) || (slot->entry.type == BM_TYPE_RENDER_TARGET_DYNAMIC) )
opengl_kill_render_target( slot );
}
/**
* API specifics for creating a user bitmap
*/
void gr_opengl_bm_create(int n)
void gr_opengl_bm_create(bitmap_slot* /*entry*/)
{
Assert( (n >= 0) && (n < MAX_BITMAPS) );
}
/**
* API specific init instructions
*/
void gr_opengl_bm_init(int n)
void gr_opengl_bm_init(bitmap_slot* slot)
{
Assert( (n >= 0) && (n < MAX_BITMAPS) );
slot->gr_info = new tcache_slot_opengl;
}
/**
@@ -86,23 +83,19 @@ void gr_opengl_bm_page_in_start()
opengl_preload_init();
}
extern void bm_clean_slot(int n);
extern bool opengl_texture_slot_valid(int n, int handle);
void gr_opengl_bm_save_render_target(int n)
void gr_opengl_bm_save_render_target(int handle)
{
Assert( (n >= 0) && (n < MAX_BITMAPS) );
if ( Cmdline_no_fbo ) {
return;
}
bitmap_entry *be = &bm_bitmaps[n];
bitmap_entry *be = bm_get_entry(handle);
bitmap *bmp = &be->bm;
size_t rc = opengl_export_render_target( n, bmp->w, bmp->h, (bmp->true_bpp == 32), be->num_mipmaps, (ubyte*)bmp->data );
size_t rc = opengl_export_render_target( handle, bmp->w, bmp->h, (bmp->true_bpp == 32), be->num_mipmaps, (ubyte*)bmp->data );
if (rc != be->mem_taken) {
Int3();
@@ -112,10 +105,8 @@ void gr_opengl_bm_save_render_target(int n)
dds_save_image(bmp->w, bmp->h, bmp->true_bpp, be->num_mipmaps, (ubyte*)bmp->data, (bmp->flags & BMP_FLAG_CUBEMAP));
}
int gr_opengl_bm_make_render_target(int n, int *width, int *height, int *bpp, int *mm_lvl, int flags)
int gr_opengl_bm_make_render_target(int handle, int *width, int *height, int *bpp, int *mm_lvl, int flags)
{
Assert( (n >= 0) && (n < MAX_BITMAPS) );
if ( Cmdline_no_fbo ) {
return 0;
}
@@ -124,7 +115,7 @@ int gr_opengl_bm_make_render_target(int n, int *width, int *height, int *bpp, in
MIN(*width, *height) = MAX(*width, *height);
}
if ( opengl_make_render_target(bm_bitmaps[n].handle, n, width, height, bpp, mm_lvl, flags) ) {
if ( opengl_make_render_target(handle, width, height, bpp, mm_lvl, flags) ) {
return 1;
}
@@ -142,9 +133,9 @@ int gr_opengl_bm_set_render_target(int n, int face)
return 1;
}
Assert( (n >= 0) && (n < MAX_BITMAPS) );
auto entry = bm_get_entry(n);
int is_static = (bm_bitmaps[n].type == BM_TYPE_RENDER_TARGET_STATIC);
int is_static = (entry->type == BM_TYPE_RENDER_TARGET_STATIC);
if ( opengl_set_render_target(n, face, is_static) ) {
return 1;
@@ -153,7 +144,7 @@ int gr_opengl_bm_set_render_target(int n, int face)
return 0;
}
bool gr_opengl_bm_data(int n, bitmap* bm)
bool gr_opengl_bm_data(int /*n*/, bitmap* /*bm*/)
{
// Do nothing here
return true;
+4 -4
View File
@@ -18,18 +18,18 @@
#include <glad/glad.h>
// anything API specific to freeing bm data
void gr_opengl_bm_free_data(int n, bool release);
void gr_opengl_bm_free_data(bitmap_slot* entry, bool release);
// API specifics for creating a user bitmap
void gr_opengl_bm_create(int n);
void gr_opengl_bm_create(bitmap_slot* entry);
// API specific init instructions
void gr_opengl_bm_init(int n);
void gr_opengl_bm_init(bitmap_slot* entry);
// specific instructions for setting up the start of a page-in session
void gr_opengl_bm_page_in_start();
bool gr_opengl_bm_data(int n, bitmap* bm);
bool gr_opengl_bm_data(int handle, bitmap* bm);
void gr_opengl_bm_save_render_target(int slot);
int gr_opengl_bm_make_render_target(int n, int *width, int *height, int *bpp, int *mm_lvl, int flags);
+1 -1
View File
@@ -75,7 +75,7 @@ inline GLenum opengl_primitive_type(primitive_type prim_type)
}
}
void gr_opengl_sphere(material* material_def, float rad)
void gr_opengl_sphere(material* material_def, float /*rad*/)
{
opengl_tnl_set_material(material_def, true);
+7 -23
View File
@@ -240,24 +240,15 @@ static opengl_shader_variant_t GL_shader_variants[] = {
static const int GL_num_shader_variants = sizeof(GL_shader_variants) / sizeof(opengl_shader_variant_t);
struct opengl_shader_feature {
const char* shader_define;
std::function<bool()> feature_test;
};
static SCP_vector<opengl_shader_feature> GL_shader_features = {
{ "FEATURE_BINDLESS_TEXTURES", []() { return gr_opengl_is_capable(CAPABILITY_BINDLESS_TEXTURING); } },
};
opengl_shader_t *Current_shader = NULL;
opengl_shader_t::opengl_shader_t() : shader(SDR_TYPE_NONE), flags(0), flags2(0)
{
}
opengl_shader_t::opengl_shader_t(opengl_shader_t&& other) {
opengl_shader_t::opengl_shader_t(opengl_shader_t&& other) SCP_NOEXCEPT {
*this = std::move(other);
}
opengl_shader_t& opengl_shader_t::operator=(opengl_shader_t&& other) {
opengl_shader_t& opengl_shader_t::operator=(opengl_shader_t&& other) SCP_NOEXCEPT {
// VS2013 doesn't support implicit move constructors so we need to explicitly declare it
shader = other.shader;
flags = other.flags;
@@ -346,7 +337,7 @@ void opengl_shader_shutdown()
GL_shader.clear();
}
static SCP_string opengl_shader_get_header(shader_type type_id, int flags, shader_stage stage) {
static SCP_string opengl_shader_get_header(shader_type type_id, int flags) {
SCP_stringstream sflags;
sflags << "#version " << GLSL_version << " core\n";
@@ -371,13 +362,6 @@ static SCP_string opengl_shader_get_header(shader_type type_id, int flags, shade
sflags << "#define " << variant.flag_text << "\n";
}
}
// Check the global shader features
for (auto& feature : GL_shader_features) {
if (feature.feature_test()) {
sflags << "#define " << feature.shader_define << "\n";
}
}
}
return sflags.str();
@@ -492,9 +476,9 @@ static SCP_string handle_includes(const char* filename, const SCP_string& origin
return output.str();
}
static SCP_vector<SCP_string> opengl_get_shader_content(shader_type type_id, const char* filename, int flags, shader_stage stage) {
static SCP_vector<SCP_string> opengl_get_shader_content(shader_type type_id, const char* filename, int flags, shader_stage) {
SCP_vector<SCP_string> parts;
parts.push_back(opengl_shader_get_header(type_id, flags, stage));
parts.push_back(opengl_shader_get_header(type_id, flags));
parts.push_back(handle_includes(filename, opengl_load_shader(filename)));
@@ -538,7 +522,7 @@ static bool do_shader_caching() {
return true;
}
static bool load_cached_shader_binary(opengl::ShaderProgram* program, SCP_string hash) {
static bool load_cached_shader_binary(opengl::ShaderProgram* program, const SCP_string& hash) {
if (!do_shader_caching()) {
return false;
}
@@ -840,7 +824,7 @@ int opengl_compile_shader(shader_type sdr, uint flags)
return sdr_index;
}
void gr_opengl_recompile_all_shaders(std::function<void(size_t, size_t)>progress_callback)
void gr_opengl_recompile_all_shaders(const std::function<void(size_t, size_t)>& progress_callback)
{
for (auto sdr = GL_shader.begin(); sdr != GL_shader.end(); ++sdr)
{
+3 -3
View File
@@ -132,8 +132,8 @@ typedef struct opengl_shader_t {
opengl_shader_t();
opengl_shader_t(opengl_shader_t&& other);
opengl_shader_t& operator=(opengl_shader_t&& other);
opengl_shader_t(opengl_shader_t&& other) SCP_NOEXCEPT;
opengl_shader_t& operator=(opengl_shader_t&& other) SCP_NOEXCEPT;
opengl_shader_t(const opengl_shader_t&) = delete;
opengl_shader_t& operator=(const opengl_shader_t&) = delete;
@@ -144,7 +144,7 @@ extern SCP_vector<opengl_shader_t> GL_shader;
extern opengl_shader_t *Current_shader;
int gr_opengl_maybe_create_shader(shader_type shader_t, unsigned int flags);
void gr_opengl_recompile_all_shaders(std::function<void(size_t, size_t)> progress_callback = nullptr);
void gr_opengl_recompile_all_shaders(const std::function<void(size_t, size_t)>& progress_callback = nullptr);
void opengl_delete_shader(int sdr_handle);
void opengl_shader_set_current(opengl_shader_t *shader_obj = NULL);
void opengl_shader_set_current(int handle);
Loaded 100 of 553 files, more files were not shown because too many files have changed in this diff. Show more