Compare commits

...
271 Commits
Author SHA1 Message Date
z64555 8b517ddda9 Adds outwindow init and the SCP_mspdbcs init and cleanup. 2016-08-15 17:45:22 -05:00
z64555 6bc5a395e0 Pointless style flag is pointless 2016-08-15 17:28:52 -05:00
z64555 318496992e Fix bug where scene would not repaint when window was resized to something smaller. 2016-08-15 17:24:55 -05:00
z64555 1e28d526ae Prevent excessive calls to wxfred::render_resize if the viewport size didn't change. 2016-08-15 16:10:48 -05:00
z64555 26a746d612 Some work on the viewport:
* Viewport now resizes. There's some kinks with re-draw to work out, though
* Viewport now displays starfield
* Viewport now displays mission grid
2016-08-15 07:24:39 -05:00
z64555 5b41dce69c Update wxfred2.cpp to use flagsets. Also a bit of whitespace maintenance (yawn). 2016-08-15 05:38:04 -05:00
z64555 ea9b611782 Merge branch 'master' of https://github.com/scp-fs2open/fs2open.github.com into wxfred2 2016-08-15 04:37:40 -05:00
m!m ddd64146d9 Merge pull request #820 from z64555/fix/filelength
Adds macro to replace instances of the deprecated filelength with...
2016-08-15 11:12:50 +02:00
MageKing17 43ca34cb4c Merge pull request #821 from SamuelCho/lightshafts_reorder
Reorder lightshafts in the post process pipeline.
2016-08-14 20:16:50 -07:00
SamuelCho 60bee02f92 Reorder lightshafts in the post process pipeline. Fixes the glare effect from being too bright. 2016-08-14 19:09:29 -07:00
z64555 2b4117256a Adds macro to replace instances of the deprecated filelength with _filelength if using MSVC. 2016-08-14 20:11:40 -05:00
z64555 9474f58820 Setup OS and FSO backend initialization.
* Currently only works on Windows due to the OpenGL loader (wxFredRender) being rather basic.
2016-08-14 19:36:16 -05:00
Fabian Woltermann d5ac9a33c1 Merge pull request #815 from asarium/feature/flagsetInitializer
Add initializer_list support for flagset
2016-08-14 17:07:33 +02:00
asarium d1baf8edca Add initializer_list support for flagset
This allows to initialize a flagset instance from a {...} expression
without having to create an intermediary instance.
2016-08-14 16:39:29 +02:00
m!m af9cc94470 Merge pull request #807 from The-E/ship_subsys_flags
Changes the subsystem flags to the new flag system.
2016-08-14 16:24:28 +02:00
z64555 6f7039ed01 Merge pull request #809 from asarium/fix/joystickGUIDs
Fix wrong joystick event assignment
2016-08-14 02:11:58 -05:00
z64555 006853ae44 Forgot to set canvas target in context creation. 2016-08-13 20:33:50 -05:00
z64555 22f56a12d9 * Implements wxFredRender's render_init() and render_frame() functions.
* Implements glcViewport's construction
2016-08-13 20:09:52 -05:00
Fabian Woltermann 8a85b5abe8 Merge pull request #811 from Echelon9/fix/legacy-mode-warning-wrapping
Improve legacy mode warning console message
2016-08-14 00:48:00 +02:00
Echelon9 69a88cf58f Improve legacy mode warning console message
Without the new line, this important warning line can get lost within
the console messages e.g. on Linux.
2016-08-13 17:44:03 -04:00
asarium a4d70c78cb Fix wrong joystick event assignment
Kobrar reported that joystick events were not properly assigned to the
right Joystick instances because the GUIDs of the joysticks was the same
(that's another problem since the code assumes that they actually are
Globally Unique like the name says).

The fix was to simply use the instance ID for checking if two sticks are
the same which seems to work more reliably.
2016-08-13 23:14:47 +02:00
m!m ecc878586c Merge pull request #808 from The-E/flagset_emergency_fix
Bugfix for flagsets
2016-08-13 21:54:15 +02:00
Fabian Woltermann d7e6e5e152 Fixes an issue in flagsets where the sanity check for flagset::set was inverted. 2016-08-13 18:26:17 +02:00
Fabian Woltermann b352a4c13a Merge pull request #770 from asarium/cmake_/ninjaColor
Enable color diagnostics for Ninja generator
2016-08-13 15:17:42 +02:00
Fabian Woltermann dc11b13edd Merge pull request #783 from MageKing17/feature/more-target-flags
Greatly expand available flags for creating target priority groups.
2016-08-13 15:17:15 +02:00
Fabian Woltermann e1ba2256ed Changes the subsystem flags to the new flag system. 2016-08-13 13:52:51 +02:00
Fabian Woltermann 0117ba446c Merge pull request #794 from z64555/fix/joystick_hats1
More compatibility code for joystick hats.
2016-08-13 11:50:24 +02:00
Fabian Woltermann 71acc296f0 Merge pull request #804 from z64555/feature/freelook
Feature/freelook
2016-08-13 11:50:06 +02:00
z64555 d24aa9f478 Remove 4-pos hat to 8-pos hat conversion code. Revert this commit if needed in the future! 2016-08-13 01:03:50 -05:00
z64555 431dd7067e More joystick hat compatibility code.
* There's now registers for both 4 position and 8 position hats for both timestamps and downcounts
* There's conversion code to allow an 8-position hat to act like a 4-position hat, which is needed by the FSO codebase which only uses 4-pos hats
* There's also conversion code to allow a 4-pos hat to act like an 8-position hat to some degree.
2016-08-13 01:03:49 -05:00
MageKing17 c17c58265a Merge pull request #805 from Echelon9/feature/readme-badges
Add badges to Readme
2016-08-12 22:17:17 -07:00
Echelon9 229a578b61 Add badges to Readme
Re-add visual badges that provide overview of build and code quality
status via Travis and Coverity.
2016-08-13 00:40:54 -04:00
z64555 994f8f7ec4 Fix bug introduced by freelook code that disabled target padlock view mode. 2016-08-12 21:47:04 -05:00
MageKing17 78de88adcf Greatly expand available flags for creating target priority groups.
Target priorities could previous only select based on very few flags, for the simple reason that very few were defined in the ai_tgt_*_flags[] arrays. This simply adds additional flags (even some that seem a little silly; I can't actually think of a reason to especially target "objects that are being rendered", but hey, maybe somebody will find a use for it in the future).
2016-08-12 19:24:07 -07:00
Fabian Woltermann 770fce8de5 Bitset flags -- take 2 (#775)
This introduces a new mechanism for handling bit flags. Instead of using an int (or two, or three) to write bits into, this uses the std::bitset in a wrapper class that accepts an enum class as input. This means that certain classes of errors we've had a few of in the engine, where a coder used the wrong set of flags or checked them against the wrong variable (SF_STEALTH vs SIF_STEALTH, for example) can now be detected at a compiler level rather than not at all.
2016-08-12 16:13:50 -07:00
z64555 b60f8742e2 Re-Re-enables the freelook mode. Somehow got lost during the Antipodes merge. 2016-08-12 18:09:24 -05:00
Fabian Woltermann 1ea71d2ba6 Merge pull request #803 from asarium/fix/fredFastDebug
Fix FRED configuration
2016-08-12 21:15:13 +02:00
asarium e8d74a833b Fix FRED configuration 2016-08-12 20:28:29 +02:00
Fabian Woltermann 97153b80a1 Merge pull request #801 from asarium/warnings/more64bit
And another batch of 64-bit fixes
2016-08-12 14:55:06 +02:00
asarium a685642554 And another batch of 64-bit fixes 2016-08-12 09:42:55 +02:00
MageKing17 96c7ea9247 Merge pull request #798 from asarium/cleanup/windebug
Remove unused code in windebug.cpp
2016-08-11 18:40:19 -07:00
MageKing17 a1c82455e4 Merge pull request #797 from asarium/warnings/evenmore64bit
Another batch of 64-bit warning fixes.
2016-08-11 18:40:09 -07:00
z64555 80f6f31f15 Merge pull request #799 from The-E/math_include_cleanup
A bit of include cleanup
2016-08-11 20:39:04 -05:00
z64555 682b279553 Merge pull request #800 from The-E/only_old_stars
Dead code cleanup in starfield.cpp
2016-08-11 20:39:01 -05:00
Fabian Woltermann 2d85ced533 Merge pull request #788 from asarium/build/sdlmain
Use the provided sdlmain library again
2016-08-11 23:04:00 +02:00
Fabian Woltermann ab315f2064 Merge pull request #792 from asarium/cleanup/disableFredDeprecation
Disable MBCS deprecation warnings in FRED
2016-08-11 23:03:40 +02:00
Fabian Woltermann b5e837a040 Merge pull request #796 from asarium/fix/memoryStats
Fix Windows memory statistics
2016-08-11 23:03:26 +02:00
Fabian Woltermann 444a9ba614 Merge pull request #789 from asarium/cmake_/msvcWarningSpecifications
Clean up CMake MSVC warning handling
2016-08-11 23:02:52 +02:00
Fabian Woltermann e103bcdf69 Removes a bit of dead code that we probably aren't going to develop any further. 2016-08-11 23:01:28 +02:00
Fabian Woltermann 44c64d79f1 Removes old int type includes we carried around from when we supported old compilers 2016-08-11 22:57:49 +02:00
asarium c40ede030a Another batch of 64-bit warning fixes. 2016-08-11 22:19:50 +02:00
asarium 76c220251b Remove unused code in windebug.cpp 2016-08-11 22:10:43 +02:00
MageKing17 affecc9285 Merge pull request #791 from asarium/warnings/more64bit
Fix even more 64-bit warnings
2016-08-11 12:54:51 -07:00
asarium c6a74c2f04 Fix Windows memory statistics 2016-08-11 21:48:11 +02:00
asarium 9a46e9b55e Fix negative shift warning
This converts the fix conversion macros to constexpr functions which
should have the same runtime effects with the added type safety.
2016-08-11 10:42:40 +02:00
asarium 6c3da4b455 Fix even more 64-bit warnings 2016-08-11 10:08:11 +02:00
z64555 83724c0d8a Merge pull request #793 from MageKing17/bugfix/invalid-joystick-buttons
Fix a couple button-related joystick issues.
2016-08-10 23:24:39 -05:00
MageKing17 9f12e1f749 Fix hat position comparison in joy_down()
getHatPosition() returns a value from the HatPosition enum, so the conversion to a 0-based index is incorrect (and causes the hat switch to basically not work with continuous controls).
2016-08-10 20:42:00 -07:00
MageKing17 7906f0b9b3 Fix allowing invalid joystick buttons through to the joystick API.
When the hat switch code was fixed to restrict joysticks to 32 buttons again, it forgot to invalidate buttons between numButtons() and 32. This could lead to some assertions being failed when the joystick got asked for the status of a nonexistent button.
2016-08-10 18:55:57 -07:00
z64555 20990416a9 Implement wxFredRender components. 2016-08-10 17:56:51 -05:00
asarium d7707053c3 Disable MBCS deprecation warnings in FRED 2016-08-10 23:44:20 +02:00
z64555 627ef75af0 Fix (undocumented) issue with hat presses not registering. (#777)
* Fix (undocumented) issue with hat presses not registering.

* Use array instead of a vector for _hat::DownCount

* No, no die-nam-ick numbor of boot-ons to-day. Und no, ve only haff vone hat. Sad Heavy is Sad.

* Fixes an out-of-bounds error caused by incorrect indexing in Joystick::handleHatEvent.
Also fixes a bug where the hatGetDownTime would return a nonzero value if the hat was active but in a different position than the input parameter.
2016-08-10 23:31:09 +02:00
MageKing17 9cef8ed64b Merge pull request #782 from asarium/fix/luaFixes
Fix a few lua related issues
2016-08-10 12:19:35 -07:00
MageKing17 8f32c6100e Merge pull request #786 from asarium/fix/grbatch
Fix wrong return type in grbatch
2016-08-10 11:26:27 -07:00
asarium 2b52c7888e Remove _cdecl usages 2016-08-10 18:03:29 +02:00
asarium 74b0702577 Specify ignored warnings in CMake toolchain file
This means that it's no longer necessary to include pstypes.h just for
ignoring the standard warnings.
2016-08-10 17:24:04 +02:00
asarium b26a70d96a Use the provided sdlmain library again 2016-08-10 16:45:04 +02:00
asarium 5b28824f62 Fix wrong return type in grbatch 2016-08-10 15:18:55 +02:00
Fabian Woltermann 9953fd924e Merge pull request #779 from asarium/warnings/more64bit
More 64-bit MSVC warning fixes
2016-08-10 14:32:21 +02:00
Fabian Woltermann 14f80e6a07 Merge pull request #784 from asarium/fix/fontHeightHack
Improve font top and bottom offset handling
2016-08-10 14:30:50 +02:00
Fabian Woltermann e805cc15fc Merge pull request #785 from asarium/fix/modelrenderVars
Fix uninitialized values in modelrender
2016-08-10 14:30:22 +02:00
asarium 0cabe71fdd More 64-bit MSVC warning fixes 2016-08-10 13:33:12 +02:00
asarium f5c0234d3b Fix uninitialized values in modelrender 2016-08-10 13:28:36 +02:00
asarium 19de867f31 Improve font top and bottom offset handling 2016-08-10 12:59:19 +02:00
niffiwan c3b4380351 Merge pull request #781 from asarium/fix/mainhallDistance
Fix wrong parameter order
2016-08-10 09:50:29 +10:00
asarium 72a956e0ed Fix wrong handle pointer validation 2016-08-10 00:06:33 +02:00
asarium 5e12ec392c Fix wrong parameter order 2016-08-10 00:03:17 +02:00
asarium 188bf2bb1e Fix wrong initial value 2016-08-09 23:55:38 +02:00
MageKing17 5f38b7fbce Merge pull request #780 from asarium/fix/shaderCrash
Fix Assert caused by invalid comparision
2016-08-09 13:58:29 -07:00
asarium b982c04a00 Fix Assert caused by invalid comparision 2016-08-09 22:24:00 +02:00
m!m 079c6ae86e Fix FRED executable version information (#778) 2016-08-09 11:15:46 -07:00
m!m 22c0255277 Fix a bunch of 64-bit MSVC warnings (#709)
* Fix a bunch of 64-bit warnings

* Fix Linux compilation error

* Fix Mac error

* Fix some issues

* Fix more GCC warnings

* Remote unwanted change

* Remove accidentally readded file

* Fix wrong limit check

* Use BEAM_INDEX macro for getting beam object index

* Fix 32-bit warning

* Use BEAM_INDEX instead of pointer arithmetic
2016-08-09 11:08:54 -07:00
asarium 526962fb60 Fix Clang warning 2016-08-09 10:44:27 +02:00
Fabian Woltermann 7265711551 Merge pull request #776 from scp-fs2open/revert-720-cleanup/update-sdl2-to-custom-libsdl
Revert "Update included SDL2.dll files to ones compiled from our custom libsdl."
2016-08-09 09:01:54 +02:00
Fabian Woltermann 5ffc569eed Merge pull request #759 from asarium/fix/hudParseErrors
Detect HUD gauges parse error and print a warning
2016-08-09 08:30:34 +02:00
Fabian Woltermann 6703007ee2 Merge pull request #761 from MageKing17/feature/allow-ai-slowdown
Add an AI flag to enable old, unused behavior when attacking big ships.
2016-08-09 08:29:58 +02:00
MageKing17 cdef2ee86a Revert "Update included SDL2.dll files to ones compiled from our custom libsdl." 2016-08-08 21:10:04 -07:00
MageKing17 552a575232 Merge pull request #773 from asarium/fix/772
Fix logic error in controlsconfig.cpp
2016-08-08 12:27:56 -07:00
asarium bfdcad1848 Fix logic error in controlsconfig.cpp
This fixes #772.
2016-08-08 19:54:12 +02:00
MageKing17 76b7c0a3d2 Merge pull request #771 from asarium/feature/noninteractive
Add noninteractive mode
2016-08-08 08:39:13 -07:00
asarium 8dbfb3a334 Fix CI failure with outdated GCC version 2016-08-08 16:49:22 +02:00
asarium 84973dd56f Use CMake variable for determining library with dlsym 2016-08-08 16:47:29 +02:00
asarium 1086e330fb Fix warnings by updating external includes 2016-08-08 16:22:39 +02:00
asarium 775d404bf1 Enable color diagnostics for Ninja generator
Also improves flags handling a bit. Previously only the C++ flags were
set, now the C flags are set as well.
2016-08-08 15:59:33 +02:00
asarium ab6c3f4ac8 Add noninteractive mode
If the -noninteractive command line option is set then dialogs won't be
shown and the default action is taken. This should be useful for
the standalone server.
2016-08-08 15:46:08 +02:00
Fabian Woltermann 302b0297b5 Merge pull request #767 from asarium/fix/64-bitFRED
Fix 64-bit compilation of FRED
2016-08-08 13:21:37 +02:00
z64555 92fc16372f Create wxFredRender files, this'll be for the graphics of wxFred and used by the glcViewport class(es). 2016-08-08 05:50:41 -05:00
z64555 cd25f907ac Merge pull request #2 from asarium/wxfred2_dev
Fix MSVC compilation issues
2016-08-08 04:33:11 -05:00
asarium c2363989e4 Fix MSVC compilation issues 2016-08-08 11:27:45 +02:00
z64555 7b13d5c1f2 Merge pull request #1 from asarium/wxfred2_dev
Fix wxFRED CMake and compliation errors
2016-08-08 04:18:56 -05:00
asarium 25f6be7867 Use the version string in the project headers 2016-08-08 11:17:05 +02:00
asarium 9756b52845 Fix wxFRED CMake and compliation errors 2016-08-08 11:17:05 +02:00
z64555 93101aa8ce Remove glrcMissionFrame. 2016-08-08 04:07:48 -05:00
z64555 10a37e6ddb Add link targets to core codebase. 2016-08-08 02:46:08 -05:00
z64555 469a31602e Fix access violation. Can't append items to wxChoice elements for the moment. 2016-08-07 23:15:43 -05:00
z64555 3521740a60 Update XRC and generated files to use wxWidgets 3.0.2 (or later. wxFormBuilder doesn't say which version it uses) 2016-08-07 23:15:42 -05:00
z64555 beaee70a82 Fix building after rebase with master. 2016-08-07 23:15:42 -05:00
z64555 eb3b65e051 Implement Copy functions, settle on using OIN_t's for object selection queues. 2016-08-07 23:15:41 -05:00
z64555 4bb547ce09 (FRED) Fix bug where AIF_NO_DYNAMIC flags weren't set with copied objects 2016-08-07 23:15:40 -05:00
z64555 5294db25b3 Implement port of core mission management functions 2016-08-07 23:15:40 -05:00
z64555 5983ddeea4 Some FRED cleanup and debugging 2016-08-07 23:15:39 -05:00
z64555 37d16a65c4 Updating README with info on wxWidget's Release packages. 2016-08-07 23:15:39 -05:00
z64555 8c54c63908 Update the README a bit. 2016-08-07 23:15:38 -05:00
z64555 ae7bf0667e Fix linking due to an unknown, removed, or renamed ailocal.h 2016-08-07 23:15:38 -05:00
z64555 c018329a4c Adds new define to disable FSO's mem* function overrides 2016-08-07 23:15:38 -05:00
z64555 f188960f91 Fixes compiling by de-tangling a #include chain that was exposed by commit 798a8922879f7af8ebd2bb07a6cdaa655a2e038b 2016-08-07 23:15:37 -05:00
niffiwan 7255d5e8e4 Update Linux to link successfully with libcode.a 2016-08-07 23:15:36 -05:00
z64555 198c6cace9 End of linkage work. (This commit is probably temporary)
* Includes wxfredstubs.cpp to prevent linkage to certain data members and functions defined in freespace.cpp.
 * "_SECURE_SCL" and "_HAS_ITERATOR_DEBUGGING" defines removed from the project files
 * C runtime library (CRT) switched to use DLL so as to integrate with wxWidgets default settings.
2016-08-07 23:15:34 -05:00
z64555 5efe85b4db Beginning setup to link into code.lib, defined some variables needed for linkage and link tests. 2016-08-07 23:15:01 -05:00
z64555 fb8fe9bb75 Started work on docFRED2, and mission load/save methods. More work done on glcViewport. 2016-08-07 23:14:59 -05:00
z64555 790f8b9d8c Some header name wrangling, a Big O snuck in somehow. 2016-08-07 23:14:03 -05:00
z64555 0bcc9f27d4 glcViewport and glrcMissionFrame classes added. README updated. 2016-08-07 23:13:59 -05:00
MageKing17 4b900bb84c Merge pull request #764 from asarium/wxFRED/graphicsInterface
Add interface for creating an OpenGL context
2016-08-07 15:42:30 -07:00
MageKing17 820d4b88be Merge pull request #769 from asarium/fix/768
Fix for #768
2016-08-07 15:38:24 -07:00
asarium 5ba393ce5d Fix for #768
Apparently MSVC 2013 allocates memory when locking a mutex which calls
our allocation hook when the tries to call our memory tracking function
which leads to a deadlock. Since there is no way of providing a memory
allocation function for std::mutex the best solution is to simply
disable the lock_guard for everything before MSVC 2015. That will
probably corrupt the memory tracking values at some point but it's
better than not being able to run FSO at all.
2016-08-07 23:45:38 +02:00
MageKing17 c76c1cb4ff Add an AI flag to enable old, unused behavior when attacking big ships.
Coverity defects 1320483, 1320484, 1320485, and 1320486 noted that several values were being set and then immediately overwritten before they could do anything. These appear to be related to behavior that Volition disabled before release that would allow the AI to slow down while attacking capital ships. It seemed a shame to waste this code, so I've added a flag to enable the behavior.
2016-08-07 14:27:59 -07:00
asarium 1fb0a57fd8 Fix 64-bit compilation of FRED 2016-08-07 23:00:17 +02:00
Fabian Woltermann 8543e99352 Merge pull request #755 from asarium/fix/gladVersion
Use the OpenGL version provided by GLAD
2016-08-07 22:28:09 +02:00
Fabian Woltermann 17e5918eeb Merge pull request #756 from asarium/cleanup/gladLoader
Improve GLAD config a bit
2016-08-07 22:27:53 +02:00
Fabian Woltermann d0ea08ed6c Merge pull request #766 from asarium/fix/linewidth
Fix for #765
2016-08-07 22:27:17 +02:00
asarium 0bf5ba092b Add interface for creating an OpenGL context
This allows to use a different method of creating and managing the
OpenGL context. This is needed of wxFRED where the OpenGL context is
created by wxWidgets. This will probably also fix #753 since it uses the
old wgl based method of creating an OpenGL context in FRED.
2016-08-07 21:38:36 +02:00
MageKing17 195b0b1d53 Merge pull request #763 from The-E/radarsetup_flag_fix
SIF_STEALTH and SF2_STEALTH are different things, I'm afraid
2016-08-07 11:41:22 -07:00
asarium 4f5ae67020 Fix for #765
glLineWidth is no longer an effective way of setting the line width of
2D operations.
2016-08-07 19:49:48 +02:00
Fabian Woltermann 580892243f SIF_STEALTH and SF2_STEALTH are different things, I'm afraid 2016-08-07 16:46:14 +02:00
niffiwan 9b537434fc Merge pull request #760 from MageKing17/coverity/1360950
Make sure va_end() gets called in ade_get_args() (fix Coverity 1360950)
2016-08-07 10:46:34 +10:00
MageKing17 5cdcd2beac Make sure va_end() gets called in ade_get_args() (fix Coverity 1360950)
If a required argument is invalid, ade_get_args() returns 0, but it wasn't making sure va_end(vl) got called first, leading to potential memory corruption (probably not a huge issue in actual usage because most people try not to release scripts that throw errors).
2016-08-06 12:57:03 -07:00
asarium 7baefbcd45 Detect HUD gauges parse error and print a warning
Previously the code simply skipped the invalid tokens and silently
ignored them. This is frustrating for modders and also let #758 slip
into the code base which would not have happened otherwise.
2016-08-06 21:40:52 +02:00
MageKing17 02aad7e5a7 Merge pull request #758 from asarium/fix/hudparse
Fix parsing code error introduced by TTF merge
2016-08-06 11:56:03 -07:00
asarium 0d165f159e Fix parsing code error introduced by TTF merge 2016-08-06 19:15:47 +02:00
asarium e6f00e37ae Improve GLAD config a bit
This removes the built-in OpenGL function pointer because we don't need
it since we are using the SDL function for that. Also explicitly uses a
compatibility loader although that has no effect on the generated code.
2016-08-06 15:24:19 +02:00
asarium 877fae7d5f Use the OpenGL version provided by GLAD 2016-08-06 15:15:23 +02:00
MageKing17 82ac53a693 Merge pull request #750 from PhantomHoover/master
Fixed actual_main to correctly return 0 on success and made
2016-08-06 00:04:54 -07:00
MageKing17 a4c6437104 Merge pull request #749 from The-E/parse_object_flag_fix
Fixes a mismatched flag type error in multiteamselect.
2016-08-06 00:04:31 -07:00
MageKing17 858df67078 Merge pull request #754 from niffiwan/fix/coverity_and_travis
Fix coverity scan triggered from travis
2016-08-06 00:04:09 -07:00
niffiwan 41b0b53b85 Fix coverity scan triggered from travis
Update modeling file to deal with SDL2.0 changes
2016-08-06 16:42:56 +10:00
Fabian Woltermann d60b756b4b Merge pull request #748 from asarium/fix/cfileArchiver
Fix compilation of cfile(archiver|extractor)
2016-08-06 08:29:13 +02:00
MageKing17 9ee98d45a2 Merge pull request #752 from asarium/fix/multiSort
Fix sorting function multi_create_sort_func
2016-08-05 15:13:41 -07:00
Fabian Woltermann fb9f3bc322 Merge pull request #751 from asarium/fix/fredOpenGL
Make sure that SDL OpenGL is initialized
2016-08-05 23:40:54 +02:00
asarium 81e3cf6fac Fix sorting function multi_create_sort_func
The function returned the wrong value for same string which caused the
MSVC debug runtime to throw an error. This fixes that.
2016-08-05 23:38:17 +02:00
asarium 0473ead31f Make sure that SDL OpenGL is initialized
The documentation says that the SDL OpenGL attributes need to be
initialized before a window is created. These changes implement that by
moving the actual SD_Window creation inside the OpenGL setup. FRED only
sets the native window handle to the correct HWND and gropengl uses
that.
2016-08-05 21:51:29 +02:00
Phantom Hoover 9ef81071fe doxygenate game_main() 2016-08-05 19:57:51 +01:00
Phantom Hoover 7b094e6966 good point mageking 2016-08-05 19:46:36 +01:00
Fabian Woltermann 88df37c6d6 Merge pull request #747 from asarium/coverity/1360947
Fix for Coverity 1360947
2016-08-05 19:19:24 +02:00
Phantom Hoover ef147c7284 Fixed actual_main to correctly return 0 on success and made
-shadow_quality imply -enable_shadows.
2016-08-05 18:10:16 +01:00
Fabian Woltermann e470d2959e Fixes a mismatched flag type error in multiteamselect. 2016-08-05 19:08:31 +02:00
asarium bc304bddfc Fix compilation of cfile(archiver|extractor) 2016-08-05 18:40:52 +02:00
Fabian Woltermann 0a0a1db421 Merge pull request #742 from asarium/fix/beamPiercingEffect
Fix variable for piercing beam particle effect
2016-08-05 18:32:48 +02:00
Fabian Woltermann dffb0c7c1d Merge pull request #746 from asarium/coverity/1320536
Fix wrong argument order in multiple functions
2016-08-05 18:32:30 +02:00
Fabian Woltermann 6dacfd8ffb Merge pull request #745 from asarium/coverity/1093292
Fix for Coverity 1093292
2016-08-05 18:32:16 +02:00
Fabian Woltermann ab17ccd424 Merge pull request #743 from asarium/fix/fredSDLMain
Call SDL_SetMainReady() in fred_init
2016-08-05 18:31:56 +02:00
asarium b408ca72f3 Fix for Coverity 1360947 2016-08-05 18:25:59 +02:00
asarium 7435d7a703 Fix for Coverity 1320538 2016-08-05 17:53:47 +02:00
asarium fa60c666bc Fix for Coverity 1320537 2016-08-05 17:50:49 +02:00
asarium 04d494e1a4 Fix for Coverity 1320536
Apparently someone mixed up left and right...
2016-08-05 17:49:01 +02:00
asarium 7e3b30f5bf Fix for Coverity 1093296 2016-08-05 17:38:57 +02:00
asarium e4783b3d34 Fix for Coverity 1093295 2016-08-05 17:37:52 +02:00
asarium 8ee84a05c0 Fix for Coverity 1093294 2016-08-05 17:35:35 +02:00
asarium 6899b1680d Fix for Coverity 1093293 2016-08-05 17:33:16 +02:00
asarium 1cfbc8859e Fix for Coverity 1093292
"Unchecked return value from library". The function can't return an
error value so I added a ml_printf (which is used at another place for
error logging as well) to log the error.
2016-08-05 17:28:44 +02:00
asarium 9a10a78ed3 Fix variable for piercing beam particle effect 2016-08-05 10:54:00 +02:00
Fabian Woltermann bd7a691b8e Merge pull request #722 from z64555/cleanup/fred
Cleanup/fred
2016-08-05 10:30:47 +02:00
asarium 6e9ce021cc Call SDL_SetMainReady() in fred_init 2016-08-05 09:58:30 +02:00
z64555 17a6896e1d Merge branch 'master' into cleanup/fred
Conflicts:
	fred2/fred.cpp
	fred2/fredrender.cpp
2016-08-04 19:18:16 -05:00
z64555 d46b17606d Fix linking with the Freespace project 2016-08-04 13:54:38 -05:00
Fabian Woltermann a570eca073 Merge pull request #739 from asarium/cmakeMerge/particlesystems
Add a new particle effect system
2016-08-04 12:46:33 +02:00
Fabian Woltermann c7f3097f7d Merge pull request #731 from asarium/fix/standaloneAssert
Fix Assertion when running in standalone mode
2016-08-04 11:28:30 +02:00
Fabian Woltermann e8954c4297 Merge pull request #733 from asarium/fix/openglVersion
Actually enforce the OpenGL 2.0 requirement
2016-08-04 11:28:07 +02:00
asarium bbeaaa1565 Add a new particle effect system
This is similar to the script I wrote a few years ago but unlike that
one, this solution doesn't kill the performance.
2016-08-04 11:08:39 +02:00
m!m 91b1d294ec Merge pull request #738 from MageKing17/coverity/1360951
Remove duplicate fclose() call (fix Coverity defect 1360951)
2016-08-03 23:26:32 +02:00
Fabian Woltermann eb164b3ff8 Merge pull request #737 from X3N0-Life-Form/lua_iff
Expose IFF to lua
2016-08-03 22:36:55 +02:00
MageKing17 4b634327e1 Remove duplicate fclose() call (fix Coverity defect 1360951)
It looks like this was added to trunk (a0f31e6), synced with antipodes (4952b70), and then one of the antipodes merges (7e77b5a) wound up combining both additions.
2016-08-03 13:28:29 -07:00
X3N0-Life-Form 625ea48d9e Expose IFF to lua
Adds the 'attacks' function to the 'team' lua type, which exposes the iff_x_attacks_y function to the lua engine.
2016-08-03 21:27:19 +02:00
Fabian Woltermann 0afe5ba8bd Merge pull request #730 from asarium/feature/openGLDebug
Use an OpenGL debug context and debug extensions
2016-08-03 11:47:49 +02:00
Fabian Woltermann 1783df6b5f Merge pull request #728 from asarium/fix/reallocCrash
Fix segfault when calling realloc
2016-08-03 11:47:30 +02:00
Fabian Woltermann 34d88d9d99 Merge pull request #735 from asarium/fix/axemFonts
Fix some font scripting bugs reported by Axem
2016-08-03 11:44:55 +02:00
Fabian Woltermann 8a9c9fb999 Merge pull request #734 from asarium/fix/luaConst
Fix const correctness in lua.cpp/.h
2016-08-03 11:28:27 +02:00
asarium 5d14899808 Fix const correctness in lua.cpp/.h 2016-08-03 10:53:23 +02:00
asarium acab2d2c46 Fix campaign list spacing 2016-08-03 10:41:09 +02:00
asarium 63f7f04502 Add error message for wrong font index 2016-08-03 10:27:22 +02:00
asarium 026564b973 Actually enforce the OpenGL 2.0 requirement 2016-08-03 09:53:51 +02:00
z64555 33ae17f00b Merge pull request #671 from asarium/feature/joystickAPI
Add improved joystick API
2016-08-03 02:21:43 -05:00
Fabian Woltermann d9a45d8dc0 Merge pull request #729 from asarium/fix/luaFontIndex
Fix off-by-one error in Lua font API
2016-08-02 23:27:38 +02:00
asarium 1679d81efa Fix Assertion when running in standalone mode
The Assertion which was triggered was carried over from the OpenGL code
but the stub code was using pretty much the same code so removing the
Assertion seems like the correct way to solve this.
2016-08-02 23:04:35 +02:00
asarium 0b5aed3e11 Use an OpenGL debug context and debug extensions
This instructs SDL to create an OpenGL debug context when a debug build
is used. Additionally it uses GL_ARB_debug_output if it's available to
provide OpenGL debug output.
2016-08-02 20:24:50 +02:00
asarium f91c681ee1 Add improved joystick API
This API allows to handle events from multiple joysticks but currently
only the events from the configured joystick are used.
2016-08-02 20:08:21 +02:00
asarium 3a63dc3800 Fix segfault when calling realloc 2016-08-02 20:00:35 +02:00
asarium 2e90049eba Fix off-by-one error in Lua font API 2016-08-02 19:39:13 +02:00
Cliff Gordon b92be0b5da Merge pull request #727 from asarium/fix/freebsd
LGTM, shouldn't even affect any other build platforms.
2016-08-02 12:38:05 -05:00
Cliff Gordon dae5c58b98 Merge pull request #723 from asarium/fix/configCase
Well, running dos2unix on it didn't create any local changes, so it looks to be entirely unix line endings now, as it should be.  LGTM.
2016-08-02 12:28:00 -05:00
asarium 1f4e40757d Fix build on FreeBSD 2016-08-02 19:10:51 +02:00
Fabian Woltermann dfc10ad8db Merge pull request #725 from asarium/fix/fontOptions
Fix code that was overwritten by TTF merge
2016-08-02 14:54:58 +02:00
asarium bb503de698 Fix code that was overwritten by TTF merge 2016-08-02 12:34:55 +02:00
Fabian Woltermann f3f4560824 Merge pull request #724 from asarium/cleanup/directx
Remove last remains of DirectX
2016-08-02 12:18:14 +02:00
Fabian Woltermann 9bfc0be819 Merge pull request #696 from asarium/cmakeMerge/memory
Add new memory tracking subsystem
2016-08-02 12:17:56 +02:00
Fabian Woltermann 36f08ca62b Merge pull request #715 from asarium/fix/fredCwd
Use the current working directory for FRED
2016-08-02 12:16:45 +02:00
Fabian Woltermann b4db345e5e Merge pull request #692 from asarium/test/ttf-3
TrueType support
2016-08-02 12:16:23 +02:00
Fabian Woltermann 2cfd82b182 Merge pull request #720 from MageKing17/cleanup/update-sdl2-to-custom-libsdl
Update included SDL2.dll files to ones compiled from our custom libsdl.
2016-08-02 12:15:51 +02:00
z64555 0c90a75900 Cleanup missionsave.h and .cpp 2016-08-02 04:24:18 -05:00
z64555 060c090827 Doxy and organize wing.h and .cpp. Probably needs a bit more cleanup. 2016-08-02 04:23:04 -05:00
z64555 a57483ffad Cleanup of mainfrm.h and .cpp 2016-08-02 04:23:02 -05:00
z64555 581e6320e1 Cleanup grid.h and .cpp 2016-08-02 04:21:56 -05:00
z64555 35dc235599 Cleanup of fredrender.h and .cpp. 2016-08-02 04:21:54 -05:00
z64555 fddbbf47bd Remove unused Preferences dialog and related variables. 2016-08-02 04:21:52 -05:00
z64555 1c4eb25e84 Cleanup freddoc.h and .cpp 2016-08-02 04:21:24 -05:00
z64555 ed3c9f1621 Cleanup of fred.h and fred.cpp 2016-08-02 04:21:22 -05:00
z64555 f836d5e002 Some header wrangling 2016-08-02 04:21:20 -05:00
z64555 2829eb5e35 Remove editor.h 2016-08-02 04:21:18 -05:00
z64555 c062a071fb Cleanup and doxy a few dialogs 2016-08-02 04:19:39 -05:00
asarium a4302fde2f Remove last remains of DirectX 2016-08-02 11:10:24 +02:00
asarium 16be3b7cc5 Add support for TrueType fonts
This allows to use standard TrueType Fonts for text rendering in FSO. It uses the NanoVG library which provides the ability of drawing 2D shapes. This library is used for most 2D operations now and can also be used directly by using the PathRenderer class.
2016-08-02 10:57:28 +02:00
asarium 9630b595e0 Make config key check case-insensitive
Fix for #719.
2016-08-02 10:39:04 +02:00
MageKing17 0d8e09f136 Merge pull request #716 from asarium/fix/fredErrorPrinting
Clean up FRED init a bit
2016-08-02 01:32:51 -07:00
m!m 44c7155f34 Merge pull request #718 from chief1983/speech_debugging
Speech Debugging
2016-08-02 10:31:00 +02:00
m!m 6a12b90df5 Merge pull request #721 from MageKing17/cleanup/remove-old-def_files
Remove old def_files.cpp file and clean up some redundant imports.
2016-08-02 10:29:16 +02:00
Cliff 8f58fa88c1 Add some debugging to the speech code for troubleshooting future issues, under the Speech filter. 2016-08-01 22:12:45 -05:00
MageKing17 dd4af145bf Remove old def_files.cpp file and clean up some redundant imports.
The CMake merge changed the default files system to include individual files instead of use a bunch of hardcoded strings, but the old file got left behind for some reason. Also, the same merge added some spurious extra imports of def_files.h which I removed at the same time (although if somebody wanted to go through and clean up all of our imports again, it'd probably be a good time for it).
2016-08-01 14:20:24 -07:00
MageKing17 253987dfb3 Update included SDL2.dll files to ones compiled from our custom libsdl. 2016-08-01 14:11:20 -07:00
SamuelCho 9a91e6041c Merge pull request #714 from The-E/fxaa-fix2
Moves the FXAA pass to after the tonemapping step
2016-08-01 10:23:01 -07:00
asarium 18154bfa60 Clean up FRED init a bit
Maybe this will help tracking down that FRED OpenGL issue
2016-08-01 19:10:51 +02:00
asarium 28f9fafa84 Use the current working directory for FRED
This allows to run the executable in a different directory. This is very
useful for debugging from within Visual Studio.
2016-08-01 18:38:21 +02:00
Fabian Woltermann e3d4cc1bc7 _actually_ move the fxaa pass 2016-08-01 11:54:00 +02:00
Fabian Woltermann 2b333fc299 Merge branch 'master' of https://github.com/scp-fs2open/fs2open.github.com into fxaa-fix2
Conflicts:
	code/graphics/gropenglpostprocessing.cpp
2016-08-01 11:48:58 +02:00
Fabian Woltermann 97c7ad43ce Moves the FXAA pass to after the tonemapping step, as recommended in the FXAA documentation 2016-08-01 11:46:45 +02:00
Fabian Woltermann 6a76b99083 Merge pull request #713 from SamuelCho/fxaa_fix
Make sure we can write to the alpha channel before doing the FXAA luminance prepass
2016-08-01 11:43:55 +02:00
SamuelCho c049c64c00 Make sure we can write to the alpha channel before doing the FXAA luminance prepass. 2016-07-31 21:04:04 -07:00
MageKing17 feb49eae9f Merge pull request #710 from asarium/fix/nestedModFolder
Fix directory creation for nested mod folders.
2016-07-30 16:05:48 -07:00
asarium 7cf42b6811 Fix directory creation for nested mod folders.
The launcher passes the mod folders as relative paths using / as the
directory separator. That path is copied into the cf_root path and when
cf_create_directory tries to create the directory, mkdir_recursive can't
handle the / in the path and tries to create two path elements at once
which is not supported by mkdir.

These changes fix that by converting mod paths to the native format
(from the / format, so it's a No-op on Unix) before using it in
cf_create_root().
2016-07-30 21:53:15 +02:00
Fabian Woltermann 42a217d48a Merge pull request #706 from asarium/cmake_/gcc-leak-check
Add option for -fsanitize=leak on GCC
2016-07-30 08:41:54 +02:00
MageKing17 24ccb7c8ff Merge pull request #707 from asarium/fix/memleak_modelinterp
Fix memory leak in modelinterp.cpp
2016-07-29 10:40:51 -07:00
m!m e3e0eae93e Merge pull request #702 from The-E/fb_thruster_adjustments
Adds a commandline switch analoguous to framebuffer shockwaves to enable the distortion effect for thrusters
2016-07-29 14:39:32 +02:00
asarium d0bfc47e59 Fix memory leak in modelinterp.cpp
bsp_info.outline_buffer was allocated but not freed when unloading the
model.
2016-07-29 12:30:21 +02:00
asarium 31712e0c48 Add option for -fsanitize=leak on GCC 2016-07-29 12:00:33 +02:00
asarium 7b352e511c Add new memory tracking subsystem
This expands the existing system which only worked on Windows to all
supported platforms.

If the MSVC debug runtime is not present then its behavior is emulated
by adding a header to each allocated memory block.
2016-07-29 11:02:45 +02:00
m!m 0819d57fd5 Merge pull request #705 from rtoijala/fix-lua51-search
Add lua51 as a possible pkg-config name
2016-07-29 10:28:00 +02:00
Fabian Woltermann d709ac3732 Merge pull request #697 from asarium/cmake_/platformChecks
Use CMake for determining if a specific header is available
2016-07-29 10:04:29 +02:00
Fabian Woltermann f30e8a3141 Merge pull request #704 from asarium/fix/cmakeConfig
Fix default CMake configuration
2016-07-29 10:04:07 +02:00
Risto Toijala baa2f9f5d7 Add lua51 as a possible pkg-config name
Basically the same as PR #628 but for CMake this time.
2016-07-29 11:00:00 +03:00
asarium 3b4e258f32 Fix default CMake configuration 2016-07-28 23:10:02 +02:00
Fabian Woltermann 624c5842c0 Merge pull request #703 from asarium/fix/submodules
Add CMake error if external modules could not be found
2016-07-28 22:36:28 +02:00
asarium 465d95dd7f Add CMake error if external modules could not be found 2016-07-28 21:16:35 +02:00
MageKing17 850824cd3c Merge pull request #701 from scp-fs2open/lab_weapon_thruster_fix
Fixes issue when rendering thrusters on weapon models
2016-07-28 12:01:51 -07:00
Fabian Woltermann 53222e66e3 Adds a commandline switch analoguous to framebuffer shockwaves to enable the distortion effect for thrusters 2016-07-28 20:22:49 +02:00
Fabian Woltermann 9f0897d916 Fixes issue when rendering thrusters on weapon models 2016-07-28 20:04:40 +02:00
Fabian Woltermann c0e67c44e8 Merge pull request #699 from asarium/ci/vsversionUpdate
Update tested visual studio versions
2016-07-28 11:36:24 +02:00
MageKing17 b40631e268 Merge pull request #698 from asarium/fix/portableMode
Expose portable mode in launcher
2016-07-28 02:17:03 -07:00
asarium 4edd6fd5a9 Update tested visual studio versions 2016-07-28 11:09:39 +02:00
asarium 690d293d9a Expose portable mode in launcher 2016-07-28 10:17:20 +02:00
Fabian Woltermann 4c53d46aec Merge pull request #695 from asarium/cmake_/appimage
Add AppImage support for nightly builds
2016-07-27 23:21:05 +02:00
asarium 06768e72d4 Use Platform checks for determining if a header is available 2016-07-27 22:24:28 +02:00
asarium 5826b880fb Add AppImage support 2016-07-27 20:53:40 +02:00
Fabian Woltermann 6646bf3002 Merge pull request #694 from asarium/fix/nightly
Fix AppVeyor Bintray config
2016-07-27 19:26:56 +02:00
asarium ea77b6fc7e Fix AppVeyor Bintray config 2016-07-27 19:24:35 +02:00
Fabian Woltermann aec35e4aba Merge pull request #693 from asarium/fix/nightly
Fix nightly BinTray user
2016-07-27 18:49:20 +02:00
asarium 676bc68beb Fix nightly BinTray user 2016-07-27 18:47:02 +02:00
Fabian Woltermann fc2a3e2869 Merge pull request #691 from asarium/fix/secureVars
Update secure variables for the main repo
2016-07-27 18:15:49 +02:00
asarium 983f1f386d Update AppVeyor variables 2016-07-27 16:12:09 +02:00
Fabian Woltermann a1582c7619 Merge pull request #690 from asarium/fix/Readme
Update readme
2016-07-27 16:03:28 +02:00
Fabian Woltermann 4a1c7ad37b Merge pull request #689 from asarium/cmake_/binarySourceDir
Don't allow binary and source directory to be the same
2016-07-27 16:03:01 +02:00
asarium b02270a6eb Update secure variables for the main repo 2016-07-27 15:57:36 +02:00
asarium 65bc829ffc Update readme 2016-07-27 15:46:04 +02:00
asarium c51d7e5676 Don't allow binary and source directory to be the same 2016-07-27 15:43:51 +02:00
438 changed files with 53713 additions and 45784 deletions

No files matched your search

+7 -7
View File
@@ -21,16 +21,14 @@ addons:
coverity_scan:
project:
name: "scp-fs2open/fs2open.github.com"
description: "Coverity via Travis CI"
notification_email: [email protected]
build_command_prepend: "./autogen.sh --enable-debug"
build_command: "make -j2"
build_command: "ci/travis/script.sh"
# must match TRAVIS_BRANCH check below
branch_pattern: coverity_scan
deploy:
- provider: releases
api_key:
secure: "bBWEBF+r4p7kea+Lj/vHD0CCW4AsxqlLri8gT3HbsdPuKwdSNU4QLLFk9yAXmmBF2T/fe45Zk+WQrdQJjSydkpG06M7sFD22RKOYv3cLF0Bq0nEG4CpuXoGqo77oFGkA5hdU6D8W2nQTMhPuiqlvhgt3zeD/6fiyfdAztbtKNRs="
secure: "Wdt4Ccefo7a0ZDjEJQJgpghh7n72FtNJuKSAPUvoz4gtEX6Ct9J8yJI1t9V3jE3CTbbLJ21/Q6eZRDfT7UfNJe5DdepoJsP9DeFhKMWqQCq+AChqQWlm0KeZAffJoJreL8vXYhnRYcLT9ceZHEH6AqwN9TPV+xJziGPISAkYNZ8="
skip_cleanup: true
file_glob: true
file: "/tmp/builds/*"
@@ -39,9 +37,9 @@ deploy:
tags: true
- provider: bintray
user: asarium
user: sirknightly
key:
secure: "JyJIsJFxCvNjmdyG9eDIvkzXFqsJQVzXKp5BeJcn5WSdMA2Vs7dCvarJXomdwe3F3RCrdmrFYCaimiCDD6LqImrcDLzxlevzGlNUv381iFna612SJj672d8iQCgtMibIJ3HzYmgZlsaJ9YcaOuccRyQIV/TNUcwgzbsW27CPEcM="
secure: "CZtvDW/zPf1Nxru21i8Wd+9hgiBRA8VowWBX0gmCOGgRq9WHISttKQQmBWGHuyVZ3rYvtE4Va2bR+2qRN+TFNkUUuOCOQkdBJTCal9nS3G/LprEmsOashG0Q5PTfMMBnlKzKxaxGJW6UhFj2GySmHEAjsFLVpuNWGJeeZgZQ3UE="
file: ci/bintray.json
on:
condition: '"$NIGHTLY_BUILD" == true'
@@ -50,6 +48,8 @@ env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
# also note that fork's don't get access to secure keys
# you have to test using a branch in the main repo
- secure: "C3wF967ZeliwwP1vC12EMIBOaC568n26Z/cPnwzn317ve59DWH3YSfPZVgvt08GzmaXITGGsJvPB+qxfGoKvQzYE4O1B73q81RpUe5pB3IhF+ThQ91VfQZIRJR5xEGJaLINUlHTTZGX5jxlkVO9wAcauVj/s3b8sQ3dvUZauPvk="
matrix:
include:
@@ -90,4 +90,4 @@ before_script:
script:
- if [ "$BUILD_DEPLOYMENT" = true ] ; then ./ci/travis/release.sh ; else ./ci/travis/script.sh ; fi
before_deploy:
- "./ci/travis/before_deploy.sh"
- "./ci/travis/before_deploy.sh"
+27 -8
View File
@@ -2,6 +2,11 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.4)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Make sure the source and binary directory are not the sample
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
message(FATAL_ERROR "Binary and source directory can not be the same! Choose another build directory.")
endif()
include(cmake/util.cmake)
# Set a few policies
@@ -23,6 +28,13 @@ ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)
SET(TARGET_COPY_FILES "" CACHE INTERNAL "" FORCE)
SET(TARGET_COPY_DIRS "" CACHE INTERNAL "" FORCE)
### Define options and editable variables in the section below:
# This is only needed for single configuration generators so don't annoy others
if(NOT CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build configuration used." FORCE)
message(WARNING "CMAKE_BUILD_TYPE was not specified, defaulting to Release configuration.")
endif(NOT CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
# Override standard CMake configurations
set(CMAKE_CONFIGURATION_TYPES Debug Release FastDebug CACHE STRING "Available configurations" FORCE)
@@ -33,6 +45,11 @@ IF(CMAKE_CROSSCOMPILING)
INCLUDE(${IMPORT_EXE_DIR}/ImportExecutables.cmake)
ENDIF(CMAKE_CROSSCOMPILING)
# Check if the external modules exists
IF(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake/external/rpavlik-cmake-modules/launcher-templates")
message(FATAL_ERROR "External submodules could not be found. Please make sure you have updated your submodules.")
endif()
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/finder")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/external/rpavlik-cmake-modules")
@@ -51,19 +68,15 @@ IF(RESET_INSTALL_PREFIX)
ENDIF(NOT $ENV{FS2PATH} STREQUAL "")
ENDIF(RESET_INSTALL_PREFIX)
### Define options and editable variables in the section below:
# This is only needed for single configuration generators so don't annoy others
if(NOT CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build configuration used." FORCE)
message(WARNING "CMAKE_BUILD_TYPE was not specified, defaulting to Release configuration.")
endif(NOT CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
IF (WIN32)
OPTION(FSO_USE_SPEECH "Use Windows specific text-to-speach libraries" ON)
OPTION(FSO_USE_VOICEREC "Enable voice recognition support" ON)
OPTION(FSO_BUILD_FRED2 "Build FRED2 binary" ON)
elseif(UNIX)
option(FSO_BUILD_APPIMAGE "Build an AppImage package" OFF)
set(APPIMAGE_ASSISTANT "" CACHE STRING "The root directory of an AppImage clone.")
ENDIF(WIN32)
OPTION(FSO_BUILD_TOOLS "Build tools related to FSO" OFF)
@@ -120,6 +133,10 @@ SET(GENERATED_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated_source)
include(generateHeaders)
if(FSO_BUILD_APPIMAGE)
include(appimage)
endif()
# This includes source code for some tools, either used in the build or also for something else
ADD_SUBDIRECTORY(tools)
@@ -161,7 +178,9 @@ IF (WIN32)
message(STATUS "Building FRED2: ${FSO_BUILD_FRED2}")
message(STATUS "Using text to speech: ${FSO_USE_SPEECH}")
message(STATUS "Using voice recogition: ${FSO_USE_VOICEREC}")
ENDIF(WIN32)
elseif(UNIX)
message(STATUS "Building AppImage: ${FSO_BUILD_APPIMAGE}")
ENDIF()
message(STATUS "Building FSO tools: ${FSO_BUILD_TOOLS}")
message(STATUS "Building wxFRED: ${FSO_BUILD_WXFRED2}")
message(STATUS "Fatal warnings: ${FSO_FATAL_WARNINGS}")
+4 -1
View File
@@ -1,8 +1,11 @@
FreeSpace2 *S*ource *C*ode *P*roject
==
[![Build Status](https://travis-ci.org/scp-fs2open/fs2open.github.com.svg?branch=master)](https://travis-ci.org/scp-fs2open/fs2open.github.com)
[![Coverity](https://img.shields.io/coverity/scan/870.svg)](https://scan.coverity.com/projects/870)
Building
--
For building you will need [CMake](http://www.cmake.org/cmake/resources/software.html). Only version 2.8.12 has been tested extensively but older version may still work. Once you have installed CMake you should create a build directory where the project/make files should be created, **do not create them inside the source tree!**<br>
For building you will need [CMake](http://www.cmake.org/cmake/resources/software.html). Version 3.4 is required. Once you have installed CMake you should create a build directory where the project/make files should be created, **do not create them inside the source tree!**<br>
<br>
On Windows you can use the `cmake-gui` executable to get a nice GUI, on Unix just use `cmake`. Use the newly created directory as build directory (change to this directory on Unix) and run cmake. On Windows this can be done by clicking the `Configure` button. Choose your compiler version and hit `Generate` when configuring is done. <br>
Depending on the makefile generator used build the `all` or `ALL_BUILD` target to compile the project.<br>
+6 -6
View File
@@ -5,9 +5,9 @@ configuration:
clone_depth: 10
environment:
matrix:
- VS_VERSION: 10
CMAKE_GENERATOR: Visual Studio 10 2010
PlatformToolset: v100
- VS_VERSION: 12
CMAKE_GENERATOR: Visual Studio 12 2013
PlatformToolset: v120_xp
- VS_VERSION: 14
CMAKE_GENERATOR: Visual Studio 14 2015
PlatformToolset: v140_xp
@@ -22,14 +22,14 @@ build_script:
deploy:
- provider: GitHub
auth_token:
secure: RWe6hwCcgBdklaYvjB62kzhKn7yDBJdqoDDKYViShaEV9HkJ75HbawsBcGBimRUu
secure: 3kV4efHXwRnfXzmJPRAOs8D7+MhwXUXYeayI/P5y114L09kJa6b6L70beXdW7yYr
on:
ReleaseBuild: true # deploy on release push only
- provider: BinTray
username: asarium
username: sirknightly
api_key:
secure: 2lHma1ZreuB4CCE5hSdp+gqFjCMzUDj3tVJhP+D6EyF5wIVMLlwXFrISwnYu1kJi
secure: pYWqfiZhIWvFYdjVWPXNaHobmnkXIWa4+LwoiyMTEiu4Z0CiCAW0ZrMfTKVkORKz
subject: scp-fs2open
repo: FSO
package: nightly
+2 -7
View File
@@ -1,10 +1,5 @@
New-Item build -type directory
Set-Location -Path build
$AdditionalFeatures="ON"
if ($Env:VS_VERSION -eq "10") {
$AdditionalFeatures="OFF"
}
cmake -DCMAKE_INSTALL_PREFIX="$env:APPVEYOR_BUILD_FOLDER/../install" -DFSO_USE_SPEECH="${AdditionalFeatures}" `
-DFSO_USE_VOICEREC="${AdditionalFeatures}" -DMSVC_SIMD_INSTRUCTIONS=SSE2 -G "$Env:CMAKE_GENERATOR" -T "$Env:PlatformToolset" ..
cmake -DCMAKE_INSTALL_PREFIX="$env:APPVEYOR_BUILD_FOLDER/../install" -DFSO_USE_SPEECH="ON" `
-DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS=SSE2 -G "$Env:CMAKE_GENERATOR" -T "$Env:PlatformToolset" ..
+3 -1
View File
@@ -13,7 +13,9 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
do
mkdir -p $config
cd $config
eval $CMAKE -DFSO_INSTALL_DEBUG_FILES=ON -DCMAKE_BUILD_TYPE=$config -DCMAKE_INSTALL_PREFIX="/tmp/release" ../..
eval $CMAKE -DFSO_INSTALL_DEBUG_FILES=ON -DCMAKE_BUILD_TYPE=$config -DCMAKE_INSTALL_PREFIX="/tmp/release" \
-DFSO_BUILD_APPIMAGE=ON -DAPPIMAGE_ASSISTANT="$HOME/AppImageAssistant" \
-DFSO_BUILD_INCLUDED_LIBS=ON ../..
cd ..
done
else
+7
View File
@@ -14,6 +14,13 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
tar -xzf /tmp/cmake.tar.gz -C $HOME/cmake/ --strip-components=1
fi
export PATH=$HOME/cmake/bin:$PATH
cd $HOME
if [ "${BUILD_DEPLOYMENT}" = true ]; then
wget -c "https://github.com/probonopd/AppImageKit/releases/download/5/AppImageAssistant" # (64-bit)
chmod a+x ./AppImageAssistant
fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
gem install xcpretty xcpretty-travis-formatter thefox-pastebin
+4 -3
View File
@@ -8,12 +8,12 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
for config in $BUILD_CONFIGS
do
cd "$config"
ninja install
ninja install appimage
cd ..
done
ls -al /tmp/release
(cd /tmp/release && tar -cvzf /tmp/builds/$PACKAGE_NAME-builds-Linux.tar.gz *)
(cd /tmp/release && tar -cvzf /tmp/builds/$PACKAGE_NAME-builds-Linux.tar.gz *.AppImage)
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
cd build
@@ -23,7 +23,8 @@ elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
| xcpretty -f `xcpretty-travis-formatter`
XCODE_RET=${PIPESTATUS[0]}
if [ "$XCODE_RET" -ne "0" ]; then
pastebin -e 1d -f build.log
tar -cvzf build.log.tar.gz build.log
curl --upload-file build.log.tar.gz "https://transfer.sh/build.log.tar.gz"
exit $XCODE_RET
fi
done
+2 -1
View File
@@ -10,7 +10,8 @@ elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
cmake --build . --config "$CONFIGURATION" | tee build.log | xcpretty -f `xcpretty-travis-formatter`
XCODE_RET=${PIPESTATUS[0]}
if [ "$XCODE_RET" -ne "0" ]; then
pastebin -e 1d -f build.log
tar -cvzf build.log.tar.gz build.log
curl --upload-file build.log.tar.gz "https://transfer.sh/build.log.tar.gz"
exit $XCODE_RET
fi
fi
+4
View File
@@ -0,0 +1,4 @@
[Desktop Entry]
Name=FreeSpace Open
Exec=$<TARGET_FILE_NAME:Freespace2>
Icon=app_icon.png
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
HERE=$(dirname $(readlink -f "${0}"))
export LD_LIBRARY_PATH="${HERE}"/lib:$PATH
"${HERE}"/bin/$<TARGET_FILE_NAME:Freespace2> $@
+23
View File
@@ -0,0 +1,23 @@
SET(BINARY_DESTINATION "bin")
SET(LIBRAY_DESTINATION "lib")
configure_file("${CMAKE_CURRENT_LIST_DIR}/AppRun.in" "${CMAKE_CURRENT_BINARY_DIR}/AppRun.gen" @ONLY)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/AppRun.gen")
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>" DESTINATION "." RENAME "AppRun")
configure_file("${CMAKE_CURRENT_LIST_DIR}/AppImage.desktop.in" "${CMAKE_CURRENT_BINARY_DIR}/AppImage.desktop.gen" @ONLY)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/AppImage.desktop.gen")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop" DESTINATION "." RENAME "fso.desktop")
install(FILES "${CMAKE_SOURCE_DIR}/freespace2/resources/app_icon.png" DESTINATION ".")
add_custom_target(appimage
COMMAND "${APPIMAGE_ASSISTANT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/fs2_open_${FSO_BINARY_SUFFIX}.AppImage")
add_dependencies(appimage install)
+1
View File
@@ -1,2 +1,3 @@
SET(BINARY_DESTINATION ".")
SET(LIBRAY_DESTINATION "${BINARY_DESTINATION}")
+8
View File
@@ -1,2 +1,10 @@
target_compile_definitions(platform INTERFACE SCP_BSD)
find_library(EXECINFO_LIB execinfo)
if (NOT EXECINFO_LIB)
message(FATAL_ERROR "Couldn't find libexecinfo! Please install it and rerun the configuration.")
else()
target_link_libraries(platform INTERFACE "${EXECINFO_LIB}")
endif()
+5 -2
View File
@@ -1,13 +1,16 @@
MESSAGE(STATUS "Configuring Windows specific things and stuff...")
target_link_libraries(platform INTERFACE comctl32.lib
target_link_libraries(platform INTERFACE
comctl32.lib
msacm32.lib
odbc32.lib
odbccp32.lib
vfw32.lib
winmm.lib
wsock32.lib)
wsock32.lib
Psapi.lib
)
target_compile_definitions(platform INTERFACE WIN32 USE_OPENAL _WINDOWS)
+5
View File
@@ -1,5 +1,6 @@
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
include(CheckLibraryExists)
@@ -8,5 +9,9 @@ include(CheckStructHasMember)
include(CheckSymbolExists)
include(CheckTypeSize)
CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
CHECK_INCLUDE_FILE_CXX("cxxabi.h" HAVE_CXXAPI_H)
set(PLATFORM_CHECK_HEADER "${GENERATED_SOURCE_DIR}/platformChecks.h")
CONFIGURE_FILE(${CMAKE_CURRENT_LIST_DIR}/platformChecks.h.in "${PLATFORM_CHECK_HEADER}")
+3
View File
@@ -3,4 +3,7 @@
#define __PLATFORM_CHECKS_H__
#pragma once
#cmakedefine HAVE_EXECINFO_H
#cmakedefine HAVE_CXXAPI_H
#endif // __PLATFORM_CHECKS_H__
+31 -20
View File
@@ -4,50 +4,61 @@ include(CheckCXXCompilerFlag)
MESSAGE(STATUS "Doing configuration specific to clang...")
unset(CMAKE_CXX_FLAGS)
message(STATUS "$ENV{CXXFLAGS}")
unset(COMPILER_FLAGS)
if(DEFINED ENV{CXXFLAGS})
message(STATUS "$ENV{CXXFLAGS}")
set(CMAKE_CXX_FLAGS $ENV{CXXFLAGS})
set(COMPILER_FLAGS $ENV{CXXFLAGS})
endif()
if(NOT CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "-march=native -pipe")
endif(NOT CMAKE_CXX_FLAGS)
if(NOT COMPILER_FLAGS)
set(COMPILER_FLAGS "-march=native -pipe")
endif()
globally_enable_extra_compiler_warnings()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops -fsigned-char -Wno-unknown-pragmas")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -funroll-loops -fsigned-char -Wno-unknown-pragmas")
# Omit "argument unused during compilation" when clang is used with ccache.
if(${CMAKE_CXX_COMPILER} MATCHES "ccache")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Qunused-arguments")
endif()
# Omit "conversion from string literal to 'char *' is deprecated" warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
if ("${CMAKE_GENERATOR}" STREQUAL "Ninja")
# Force color diagnostics for Ninja generator
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fdiagnostics-color")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-char-subscripts")
# Omit "deprecated conversion from string constant to 'char*'" warnings.
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-write-strings")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-function")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-deprecated -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(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-shift-negative-value")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-shift-negative-value")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wno-unused-variable")
set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wshadow")
set(COMPILER_FLAGS_DEBUG "-O0 -g -Wshadow")
if (FSO_FATAL_WARNINGS)
# Make warnings fatal if the right variable is set
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Werror")
endif()
set(CMAKE_CXX_FLAGS ${COMPILER_FLAGS})
set(CMAKE_C_FLAGS ${COMPILER_FLAGS})
set(CMAKE_CXX_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
set(CMAKE_C_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
set(CMAKE_CXX_FLAGS_DEBUG ${COMPILER_FLAGS_DEBUG})
set(CMAKE_C_FLAGS_DEBUG ${COMPILER_FLAGS_DEBUG})
set(CMAKE_EXE_LINKER_FLAGS "")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "")
+43 -14
View File
@@ -1,41 +1,70 @@
include(EnableExtraCompilerWarnings)
include(CheckCCompilerFlag)
include(util)
MESSAGE(STATUS "Doing configuration specific to gcc...")
unset(CMAKE_CXX_FLAGS)
option(GCC_ENABLE_LEAK_CHECK "Enable the -fsanitize=leak" OFF)
unset(COMPILER_FLAGS)
if(DEFINED ENV{CXXFLAGS})
set(CMAKE_CXX_FLAGS $ENV{CXXFLAGS})
message("${CMAKE_CXX_FLAGS}")
set(COMPILER_FLAGS $ENV{CXXFLAGS})
endif()
if(NOT CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "-march=native -pipe")
endif(NOT CMAKE_CXX_FLAGS)
if(NOT COMPILER_FLAGS)
set(COMPILER_FLAGS "-march=native -pipe")
endif()
globally_enable_extra_compiler_warnings()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops -fsigned-char -Wno-unknown-pragmas")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -funroll-loops -fsigned-char -Wno-unknown-pragmas")
if ("${CMAKE_GENERATOR}" STREQUAL "Ninja")
# Force color diagnostics for Ninja generator
CHECK_C_COMPILER_FLAG(-fdiagnostics-color SUPPORTS_DIAGNOSTIC_COLOR)
if(SUPPORTS_DIAGNOSTIC_COLOR)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fdiagnostics-color")
endif()
endif()
# Omit "deprecated conversion from string constant to 'char*'" warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-write-strings")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-function")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-char-subscripts")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-deprecated -Wno-char-subscripts")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-unused-parameter")
set(CMAKE_CXX_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")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wshadow")
set(COMPILER_FLAGS_DEBUG "-O0 -g -Wshadow")
if (FSO_FATAL_WARNINGS)
# Make warnings fatal if the right variable is set
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Werror")
endif()
set(CMAKE_CXX_FLAGS ${COMPILER_FLAGS})
set(CMAKE_C_FLAGS ${COMPILER_FLAGS})
set(CMAKE_CXX_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
set(CMAKE_C_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
set(CMAKE_CXX_FLAGS_DEBUG ${COMPILER_FLAGS_DEBUG})
set(CMAKE_C_FLAGS_DEBUG ${COMPILER_FLAGS_DEBUG})
set(CMAKE_EXE_LINKER_FLAGS "")
if (GCC_ENABLE_LEAK_CHECK)
check_linker_flag("-fsanitize=leak" SUPPORTS_FSANITIZE_LEAK)
if (SUPPORTS_FSANITIZE_LEAK)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=leak")
endif()
endif()
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-g -rdynamic")
+25
View File
@@ -10,6 +10,31 @@ set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS Debug)
option(MSVC_USE_RUNTIME_DLL "Use the dynamically linked version of the runtime" OFF)
MARK_AS_ADVANCED(FORCE MSVC_USE_RUNTIME_DLL)
# These are the warnings we disable
set(WARNING_FLAGS
/wd"4100" # unreferenced formal parameters
/wd"4127" # constant conditional (assert)
/wd"4201" # nonstandard extension used: nameless struct/union (happens a lot in Windows include headers)
/wd"4290" # C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
/wd"4390" # empty control statement (triggered by nprintf and mprintf's inside of one-line if's, etc)
/wd"4410" # illegal size for operand... ie... fxch st(1)
/wd"4511" # copy constructor could not be generated (happens a lot in Windows include headers)
/wd"4512" # assignment operator could not be generated (happens a lot in Windows include headers)
/wd"4514" # unreferenced inline function removed
/wd"4611" # _setjmp warning. Since we use setjmp alot, and we don't really use constructors or destructors, this warning doesn't really apply to us.
/wd"4663" # C++ language change (template specification)
/wd"4710" # is inline function not expanded (who cares?)
/wd"4711" # tells us an inline function was expanded (who cares?)
/wd"4786" # is identifier truncated to 255 characters (happens all the time in Microsoft #includes) -- Goober5000"
/wd"4996" # deprecated strcpy, strcat, sprintf, etc. (from MSVC 2005) - taylor
/wd"4311" # Disables warnings about casting pointer types to ints. The funny thing is these warnings can't be resolved, just disabled... - m!m
/wd"4302" # Same as above - m!m
/wd"4366" # The result of the unary '&' operator may be unaligned - m!m
$<$<CONFIG:Release>:/wd"4101"> # In release mode there are unreferenced variables because debug needs them
)
target_compile_options(compiler INTERFACE ${WARNING_FLAGS})
# Base
set(CMAKE_C_FLAGS "/MP /GS- /analyze- /Zc:wchar_t /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo")
set(CMAKE_CXX_FLAGS "/MP /GS- /analyze- /Zc:wchar_t /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo")
+39
View File
@@ -1,4 +1,6 @@
include(CheckCCompilerFlag)
FUNCTION(MAKE_CACHE_INTERNAL VARIABLE)
SET(${VARIABLE} ${${VARIABLE}} CACHE INTERNAL "Internal cache variable")
ENDFUNCTION(MAKE_CACHE_INTERNAL)
@@ -74,6 +76,38 @@ MACRO(COPY_FILES_TO_TARGET _target)
ENDFOREACH(file)
ENDMACRO(COPY_FILES_TO_TARGET)
macro(_clear_old_libraries_state)
set(is_debug FALSE)
set(is_optimized FALSE)
endmacro(_clear_old_libraries_state)
function(CONVERT_OLD_LIBRARIES)
_clear_old_libraries_state()
set(out_list)
foreach(lib ${ARGV})
if ("${lib}" STREQUAL "debug")
_clear_old_libraries_state()
set(is_debug TRUE)
elseif("${lib}" STREQUAL "optimized")
_clear_old_libraries_state()
set(is_optimized TRUE)
elseif("${lib}" STREQUAL "general")
_clear_old_libraries_state()
else("${lib}" STREQUAL "debug")
# Expecting normal library
if(is_debug)
list(APPEND out_list "$<$<CONFIG:Debug>:${lib}>")
elseif(is_optimized)
list(APPEND out_list "$<$<CONFIG:Release>:${lib}>")
else(is_debug)
list(APPEND out_list "${lib}")
endif(is_debug)
endif("${lib}" STREQUAL "debug")
endforeach(lib)
set(CONVERTED_LIBRARIES ${out_list} PARENT_SCOPE)
endfunction(CONVERT_OLD_LIBRARIES)
macro(set_policy policy value)
if (POLICY ${policy})
cmake_policy(SET ${policy} ${value})
@@ -128,3 +162,8 @@ function(detect_simd_instructions _out_var)
ENDIF(COMPILE_RESULT)
endif()
endfunction()
function (check_linker_flag _flag _out_var)
SET(CMAKE_REQUIRED_FLAGS "${_flag}")
CHECK_C_COMPILER_FLAG("" ${_out_var})
endfunction(check_linker_flag)
+1 -1
View File
@@ -19,7 +19,7 @@ TARGET_INCLUDE_DIRECTORIES(code PUBLIC ${FREESPACE_HEADERS})
TARGET_INCLUDE_DIRECTORIES(code PUBLIC ${GENERATED_SOURCE_DIR})
TARGET_INCLUDE_DIRECTORIES(code PUBLIC ${GENERATED_SOURCE_DIR}/code)
target_link_libraries(code PUBLIC OpenGL)
target_link_libraries(code PUBLIC gl_12)
TARGET_LINK_LIBRARIES(code PUBLIC ${OPENAL_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC ${LUA_LIBS})
+2 -1
View File
@@ -10,7 +10,6 @@
#include "globalincs/pstypes.h"
#include "def_files/def_files.h"
#include "ai/ai_profiles.h"
#include "def_files/def_files.h"
#include "globalincs/pstypes.h"
#include "localization/localize.h"
#include "parse/parselo.h"
@@ -468,6 +467,8 @@ void parse_ai_profiles_tbl(const char *filename)
set_flag(profile, "$glide decay requires thrust:", AIPF2_GLIDE_DECAY_REQUIRES_THRUST, AIP_FLAG2);
set_flag(profile, "$ai can slow down when attacking big ships:", AIPF2_AI_CAN_SLOW_DOWN_ATTACKING_BIG_SHIPS, AIP_FLAG2);
profile->bay_arrive_speed_mult = 1.0f;
profile->bay_depart_speed_mult = 1.0f;
if (optional_string("$bay arrive speed multiplier:")) {
+1
View File
@@ -68,6 +68,7 @@
#define AIPF2_STRICT_TURRET_TAGGED_ONLY_TARGETING (1 << 14)
#define AIPF2_ASPECT_INVULNERABILITY_FIX (1 << 15)
#define AIPF2_GLIDE_DECAY_REQUIRES_THRUST (1 << 16)
#define AIPF2_AI_CAN_SLOW_DOWN_ATTACKING_BIG_SHIPS (1 << 17)
// AI Path types
#define AI_PATH_MODE_NORMAL 0
+34 -31
View File
@@ -510,7 +510,7 @@ int ai_big_maybe_start_strafe(ai_info *aip, ship_info *sip)
{
// if moving slowly (or stopped), and SIF_SMALL_SHIP, then enter STRAFE mode if enemy fighter/bombers
// are near
if ( sip->flags & SIF_SMALL_SHIP ) {
if ( sip->is_small_ship() ) {
if ( timestamp_elapsed(aip->scan_for_enemy_timestamp) ) {
ship_obj *so;
object *test_objp;
@@ -525,7 +525,7 @@ int ai_big_maybe_start_strafe(ai_info *aip, ship_info *sip)
test_sp = &Ships[test_objp->instance];
if ( iff_x_attacks_y(Ships[Pl_objp->instance].team, test_sp->team) ) {
if ( Ship_info[test_sp->ship_info_index].flags & SIF_SMALL_SHIP ) {
if ( Ship_info[test_sp->ship_info_index].is_small_ship() ) {
dist_squared = vm_vec_dist_squared(&Pl_objp->pos, &test_objp->pos);
if ( dist_squared < ENTER_STRAFE_THREAT_DIST_SQUARED ) {
return 1;
@@ -641,7 +641,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
accelerate_ship(aip, 1.0f);
ship *shipp = &Ships[Pl_objp->instance];
if ((aip->ai_flags & AIF_FREE_AFTERBURNER_USE) && !(shipp->flags2 & SF2_AFTERBURNER_LOCKED) && (dot_to_enemy > 0.75f)) {
if ((aip->ai_flags & AIF_FREE_AFTERBURNER_USE) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (dot_to_enemy > 0.75f)) {
if (ai_maybe_fire_afterburner(Pl_objp, aip)) {
afterburners_start(Pl_objp);
aip->afterburner_stop_time = Missiontime + 3*F1_0;
@@ -683,7 +683,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vec3d *enemy_pos, float d
accelerate_ship(aip, accel);
ship *shipp = &Ships[Pl_objp->instance];
if ((aip->ai_flags & AIF_FREE_AFTERBURNER_USE) && !(shipp->flags2 & SF2_AFTERBURNER_LOCKED) && (accel > 0.95f)) {
if ((aip->ai_flags & AIF_FREE_AFTERBURNER_USE) && !(shipp->flags[Ship::Ship_Flags::Afterburner_locked]) && (accel > 0.95f)) {
if (ai_maybe_fire_afterburner(Pl_objp, aip)) {
afterburners_start(Pl_objp);
aip->afterburner_stop_time = Missiontime + 3*F1_0;
@@ -748,15 +748,15 @@ void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy, vec3d *f
}
if (tswp->num_secondary_banks > 0) {
if (!(En_objp->flags & OF_PROTECTED) || (aip->goals[0].ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP))) {
if (!(En_objp->flags[Object::Object_Flags::Protected]) || (aip->goals[0].ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP))) {
ai_choose_secondary_weapon(Pl_objp, aip, En_objp);
int current_bank = tswp->current_secondary_bank;
if (current_bank > -1) {
weapon_info *swip = &Weapon_info[tswp->secondary_bank_weapons[current_bank]];
if(!(En_objp->flags & OF_PROTECTED) || ((aip->goals[0].ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP)) && swip->wi_flags & WIF_PUNCTURE )) { //override lockdown on protected ships when using anti subsystem weapons - Valathil
if(!(En_objp->flags[Object::Object_Flags::Protected]) || ((aip->goals[0].ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP)) && swip->wi_flags & WIF_PUNCTURE )) { //override lockdown on protected ships when using anti subsystem weapons - Valathil
// If ship is protected and very low on hits, don't fire missiles.
if (!(En_objp->flags & OF_PROTECTED) || (En_objp->hull_strength > 10*swip->damage)) {
if (!(En_objp->flags[Object::Object_Flags::Protected]) || (En_objp->hull_strength > 10*swip->damage)) {
if (aip->ai_flags & AIF_UNLOAD_SECONDARIES) {
if (timestamp_until(swp->next_secondary_fire_stamp[current_bank]) > swip->fire_wait*1000.0f) {
swp->next_secondary_fire_stamp[current_bank] = timestamp((int) (swip->fire_wait*1000.0f));
@@ -771,7 +771,7 @@ void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy, vec3d *f
firing_range = MIN((swip->max_speed * swip->lifetime), swip->weapon_range);
// reduce firing range of secondaries in nebula
extern int Nebula_sec_range;
if ((The_mission.flags & MISSION_FLAG_FULLNEB) && Nebula_sec_range) {
if ((The_mission.flags[Mission::Mission_Flags::Fullneb]) && Nebula_sec_range) {
firing_range *= 0.8f;
}
@@ -914,10 +914,10 @@ void ai_big_chase()
dist_to_enemy = vm_vec_normalized_dir(&vec_to_enemy, &enemy_pos, &player_pos); // - En_objp->radius;
dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.vec.fvec);
update_aspect_lock_information(aip, &vec_to_enemy, dist_to_enemy, En_objp->radius);
} else if (En_objp->flags & OF_PROTECTED) { // If protected and we're not attacking a subsystem, stop attacking!
} else if (En_objp->flags[Object::Object_Flags::Protected]) { // If protected and we're not attacking a subsystem, stop attacking!
update_aspect_lock_information(aip, &vec_to_enemy, dist_to_enemy - En_objp->radius, En_objp->radius);
aip->target_objnum = -1;
if (find_enemy(Pl_objp-Objects, MAX_ENEMY_DISTANCE, The_mission.ai_profile->max_attackers[Game_skill_level]) == -1) {
if (find_enemy(OBJ_INDEX(Pl_objp), MAX_ENEMY_DISTANCE, The_mission.ai_profile->max_attackers[Game_skill_level]) == -1) {
ai_do_default_behavior(Pl_objp);
return;
}
@@ -1174,7 +1174,7 @@ void ai_big_attack_get_data(vec3d *enemy_pos, float *dist_to_enemy, float *dot_t
Assert(aip->mode == AIM_STRAFE);
// ensure that Pl_objp is still targeting a big ship
if ( !(esip->flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) ) {
if ( !(esip->is_big_or_huge()) ) {
ai_big_switch_to_chase_mode(aip);
return;
}
@@ -1350,27 +1350,30 @@ void ai_big_strafe_attack()
ai_big_maybe_fire_weapons(target_dist, target_dot, &Pl_objp->pos, &En_objp->pos, &En_objp->phys_info.vel);
turn_towards_point(Pl_objp, &target_pos, NULL, 0.0f);
// Slow down if we've not been hit for a while
fix last_hit = Missiontime - aip->last_hit_time;
if ( target_dist > 1200 || last_hit < F1_0*6) {
accel = 1.0f;
} else {
float attack_time;
attack_time = f2fl(Missiontime - aip->submode_start_time);
if ( attack_time > 15 ) {
accel = 0.2f;
} else if ( attack_time > 10 ) {
accel = 0.4f;
} else if ( attack_time > 8 ) {
accel = 0.6f;
} else if ( attack_time > 5 ) {
accel = 0.8f;
} else {
if ( aip->ai_profile_flags2 & AIPF2_AI_CAN_SLOW_DOWN_ATTACKING_BIG_SHIPS ) {
// Slow down if we've not been hit for a while
if ( target_dist > 1200 || last_hit < F1_0*6) {
accel = 1.0f;
} else {
float attack_time;
attack_time = f2fl(Missiontime - aip->submode_start_time);
if ( attack_time > 15 ) {
accel = 0.2f;
} else if ( attack_time > 10 ) {
accel = 0.4f;
} else if ( attack_time > 8 ) {
accel = 0.6f;
} else if ( attack_time > 5 ) {
accel = 0.8f;
} else {
accel = 1.0f;
}
}
} else {
accel = 1.0f;
}
accel = 1.0f;
accelerate_ship(aip, accel);
// if haven't been hit in quite a while, leave strafe mode
@@ -1651,7 +1654,7 @@ void ai_big_strafe()
}
*/
// check if target is still a big ship... if not enter chase mode
if ( !(Ship_info[Ships[En_objp->instance].ship_info_index].flags & (SIF_BIG_SHIP|SIF_HUGE_SHIP)) ) {
if ( !(Ship_info[Ships[En_objp->instance].ship_info_index].is_big_or_huge()) ) {
ai_big_switch_to_chase_mode(aip);
return;
}
@@ -1724,12 +1727,12 @@ int ai_big_maybe_enter_strafe_mode(object *pl_objp, int weapon_objnum, int consi
// if Pl_objp's target is not a big/capital ship, then cannot enter strafe mode
// AL 12-31-97: Even though transports are considered big ships, don't enter strafe mode on them
if ( !(sip->flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) || (sip->flags & SIF_TRANSPORT) ) {
if ( !(sip->is_big_or_huge()) || (sip->flags[Ship::Info_Flags::Transport]) ) {
return 0;
}
// If Pl_objp not a fighter or bomber, don't enter strafe mode. -- MK, 11/11/97.
if ( !(Ship_info[Ships[pl_objp->instance].ship_info_index].flags & (SIF_FIGHTER | SIF_BOMBER)) ) {
if ( !(Ship_info[Ships[pl_objp->instance].ship_info_index].is_fighter_bomber()) ) {
return 0;
}
@@ -1751,7 +1754,7 @@ int ai_big_maybe_enter_strafe_mode(object *pl_objp, int weapon_objnum, int consi
//JAS IMPOSSIBLE } else {
// switch targets
sip = &Ship_info[Ships[parent_objp->instance].ship_info_index];
if ( !(sip->flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) || (sip->flags & SIF_TRANSPORT) ) {
if ( !(sip->is_big_or_huge()) || (sip->flags[Ship::Info_Flags::Transport]) ) {
return 0;
}
set_target_objnum(aip, OBJ_INDEX(parent_objp));
+216 -207
View File
File diff suppressed because it is too large. Load diff
+8 -8
View File
@@ -584,10 +584,10 @@ void ai_goal_fixup_dockpoints(ai_info *aip, ai_goal *aigp)
// look for docking points of the appriopriate type. Use cargo docks for cargo ships.
/*
if (Ship_info[Ships[shipnum].ship_info_index].flags & SIF_CARGO) {
if (Ship_info[Ships[shipnum].ship_info_index].flags[Ship::Info_Flags::Cargo]) {
docker_index = ai_goal_find_dockpoint(aip->shipnum, DOCK_TYPE_CARGO);
dockee_index = ai_goal_find_dockpoint(shipnum, DOCK_TYPE_CARGO);
} else if (Ship_info[Ships[aip->shipnum].ship_info_index].flags & SIF_SUPPORT) {
} else if (Ship_info[Ships[aip->shipnum].ship_info_index].flags[Ship::Info_Flags::Support]) {
docker_index = ai_goal_find_dockpoint(aip->shipnum, DOCK_TYPE_REARM);
dockee_index = ai_goal_find_dockpoint(shipnum, DOCK_TYPE_REARM);
}
@@ -1387,7 +1387,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
ship *shipp = &Ships[objp->instance];
// always valid if has subspace drive
if (!(shipp->flags2 & SF2_NO_SUBSPACE_DRIVE))
if (!(shipp->flags[Ship::Ship_Flags::No_subspace_drive]))
return AI_GOAL_ACHIEVABLE;
// if no subspace drive, only valid if our mothership is present
@@ -1661,7 +1661,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
}
// if ship is disabled, don't know if it can dock or not
if ( Ships[objp->instance].flags & SF_DISABLED )
if ( Ships[objp->instance].flags[Ship::Ship_Flags::Disabled] )
return AI_GOAL_NOT_KNOWN;
// we must also determine if we're prevented from docking for any reason
@@ -1807,7 +1807,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp )
// if the destination ship is dying or departing (but not completed yet), the mark goal as
// not achievable.
if ( Ships[sindex].flags & (SF_DYING | SF_DEPARTING) )
if ( Ships[sindex].is_dying_or_departing())
return AI_GOAL_NOT_ACHIEVABLE;
// if the destination object is no longer awaiting repair, then remove the item
@@ -2042,7 +2042,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
// Goober5000 - we may want to use AI for the player
// AL 3-7-98: If this is a player ship, and the goal is not a formation goal, then do a quick out
if ( !(Player_use_ai) && (objp->flags & OF_PLAYER_SHIP) && (current_goal->ai_mode != AI_GOAL_FORM_ON_WING) )
if ( !(Player_use_ai) && (objp->flags[Object::Object_Flags::Player_ship]) && (current_goal->ai_mode != AI_GOAL_FORM_ON_WING) )
{
return;
}
@@ -2199,11 +2199,11 @@ void ai_process_mission_orders( int objnum, ai_info *aip )
if (aip->target_objnum != -1) {
// Only protect if _not_ a capital ship. We don't want the Lucifer accidentally getting protected.
if (Ship_types[Ship_info[Ships[shipnum].ship_info_index].class_type].ai_bools & STI_AI_PROTECTED_ON_CRIPPLE)
Objects[aip->target_objnum].flags |= OF_PROTECTED;
Objects[aip->target_objnum].flags.set(Object::Object_Flags::Protected);
}
} else // Just in case this ship had been protected, unprotect it.
if (aip->target_objnum != -1)
Objects[aip->target_objnum].flags &= ~OF_PROTECTED;
Objects[aip->target_objnum].flags.remove(Object::Object_Flags::Protected);
break;
}
+65 -64
View File
@@ -522,17 +522,17 @@ int valid_turret_enemy(object *objp, object *turret_parent)
sip = &Ship_info[shipp->ship_info_index];
// don't fire at ships with protected bit set!!!
if ( objp->flags & OF_PROTECTED ) {
if ( objp->flags[Object::Object_Flags::Protected] ) {
return 0;
}
// don't shoot at ships without collision check
if (!(objp->flags & OF_COLLIDES)) {
if (!(objp->flags[Object::Object_Flags::Collides])) {
return 0;
}
// don't shoot at arriving ships
if (shipp->flags & SF_ARRIVING) {
if (shipp->is_arriving()) {
return 0;
}
@@ -604,48 +604,48 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
}
// check if protected
if (objp->flags & OF_PROTECTED) {
if (objp->flags[Object::Object_Flags::Protected]) {
return;
}
// check if beam protected
if (eeo->eeo_flags & EEOF_BEAM) {
if (objp->flags & OF_BEAM_PROTECTED) {
if (objp->flags[Object::Object_Flags::Beam_protected]) {
return;
}
}
// check if flak protected
if (eeo->eeo_flags & EEOF_FLAK) {
if (objp->flags & OF_FLAK_PROTECTED) {
if (objp->flags[Object::Object_Flags::Flak_protected]) {
return;
}
}
// check if laser protected
if (eeo->eeo_flags & EEOF_LASER) {
if (objp->flags & OF_LASER_PROTECTED) {
if (objp->flags[Object::Object_Flags::Laser_protected]) {
return;
}
}
// check if missile protected
if (eeo->eeo_flags & EEOF_MISSILE) {
if (objp->flags & OF_MISSILE_PROTECTED) {
if (objp->flags[Object::Object_Flags::Missile_protected]) {
return;
}
}
// don't shoot at small ships if we shouldn't
if (eeo->eeo_flags & EEOF_BIG_ONLY) {
if (!(Ship_info[shipp->ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) {
if (!(Ship_info[shipp->ship_info_index].is_big_or_huge())) {
return;
}
}
// don't shoot at big ships if we shouldn't
if (eeo->eeo_flags & EEOF_SMALL_ONLY) {
if ((Ship_info[shipp->ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) {
if ((Ship_info[shipp->ship_info_index].is_big_or_huge())) {
return;
}
}
@@ -730,7 +730,7 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
if ( Weapons[objp->instance].homing_object == &Objects[eeo->turret_parent_objnum] ) {
if ( dist_comp < eeo->nearest_homing_bomb_dist ) {
if (!(ss->flags & SSF_FOV_REQUIRED) && (eeo->current_enemy == -1)) {
if (!(ss->flags[Ship::Subsystem_Flags::FOV_Required]) && (eeo->current_enemy == -1)) {
turret_has_no_target = true;
}
if ( (turret_has_no_target) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
@@ -741,7 +741,7 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
// if not homing, check if bomb is flying towards ship
} else if ( bomb_headed_towards_ship(objp, &Objects[eeo->turret_parent_objnum]) ) {
if ( dist_comp < eeo->nearest_bomb_dist ) {
if (!(ss->flags & SSF_FOV_REQUIRED) && (eeo->current_enemy == -1)) {
if (!(ss->flags[Ship::Subsystem_Flags::FOV_Required]) && (eeo->current_enemy == -1)) {
turret_has_no_target = true;
}
if ( (turret_has_no_target) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
@@ -753,7 +753,7 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
} // end weapon section
// maybe recalculate dist for big or huge ship
// if (shipp && (Ship_info[shipp->ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) {
// if (shipp && (Ship_info[shipp->ship_info_index].is_big_or_huge())) {
// fvi_ray_boundingbox(min, max, start, direction, hit);
// dist = vm_vec_dist_quick(hit, tvec);
// }
@@ -770,11 +770,11 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
// return if we're over the cap
// int max_turrets = 3 + Game_skill_level * Game_skill_level;
int max_turrets = The_mission.ai_profile->max_turret_ownage_target[Game_skill_level];
if (objp->flags & OF_PLAYER_SHIP) {
if (objp->flags[Object::Object_Flags::Player_ship]) {
max_turrets = The_mission.ai_profile->max_turret_ownage_player[Game_skill_level];
}
// Apply the per-turret limit for small targets, if there is one and this is a small target
if (ss->turret_max_target_ownage != -1 && (Ship_info[shipp->ship_info_index].flags & (SIF_SMALL_SHIP))) {
if (ss->turret_max_target_ownage != -1 && (Ship_info[shipp->ship_info_index].is_small_ship())) {
max_turrets = MIN(max_turrets, ss->system_info->turret_max_target_ownage);
}
if (num_att_turrets > max_turrets) {
@@ -783,7 +783,7 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
// modify distance based on lethality of objp to my ship
float active_lethality = aip->lethality;
if (objp->flags & OF_PLAYER_SHIP) {
if (objp->flags[Object::Object_Flags::Player_ship]) {
active_lethality += Player_lethality_bump[Game_skill_level];
}
@@ -804,7 +804,7 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
// maybe update nearest attacker
if ( dist_comp < eeo->nearest_attacker_dist ) {
if (!(ss->flags & SSF_FOV_REQUIRED) && (eeo->current_enemy == -1)) {
if (!(ss->flags[Ship::Subsystem_Flags::FOV_Required]) && (eeo->current_enemy == -1)) {
turret_has_no_target = true;
}
if ( (turret_has_no_target) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
@@ -822,7 +822,7 @@ void evaluate_obj_as_target(object *objp, eval_enemy_obj_struct *eeo)
dist_comp *= 0.9f + (0.01f * asteroid_time_to_impact(objp));
if (dist_comp < eeo->nearest_dist ) {
if (!(ss->flags & SSF_FOV_REQUIRED) && (eeo->current_enemy == -1)) {
if (!(ss->flags[Ship::Subsystem_Flags::FOV_Required]) && (eeo->current_enemy == -1)) {
turret_has_no_target = true;
}
if ( (turret_has_no_target) || object_in_turret_fov(objp, ss, eeo->tvec, eeo->tpos, dist + objp->radius) ) {
@@ -843,12 +843,12 @@ int is_target_beam_valid(ship_weapon *swp, object *objp)
{
// check if turret has beam weapon
if (all_turret_weapons_have_flags(swp, WIF_BEAM)) {
if (objp->flags & OF_BEAM_PROTECTED) {
if (objp->flags[Object::Object_Flags::Beam_protected]) {
return 0;
}
if (all_turret_weapons_have_flags(swp, WIF_HUGE)) {
if (objp->type == OBJ_SHIP && !(Ship_info[Ships[objp->instance].ship_info_index].flags & (SIF_BIG_SHIP|SIF_HUGE_SHIP)) ) {
if (objp->type == OBJ_SHIP && !(Ship_info[Ships[objp->instance].ship_info_index].is_big_or_huge()) ) {
return 0;
}
}
@@ -1008,21 +1008,22 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs
}
}
if( ( (tt->wif2_flags != 0) || (tt->wif_flags != 0) ) && (ptr->type == OBJ_WEAPON) ) {
if( ( (tt->wif_flags != 0) || (tt->wif2_flags != 0) || (tt->wif3_flags != 0) ) && (ptr->type == OBJ_WEAPON) ) {
if( ( (Weapon_info[Weapons[ptr->instance].weapon_info_index].wi_flags & tt->wif_flags ) == tt->wif_flags)
&& ( (Weapon_info[Weapons[ptr->instance].weapon_info_index].wi_flags2 & tt->wif2_flags ) == tt->wif2_flags) ) {
&& ( (Weapon_info[Weapons[ptr->instance].weapon_info_index].wi_flags2 & tt->wif2_flags ) == tt->wif2_flags)
&& ( (Weapon_info[Weapons[ptr->instance].weapon_info_index].wi_flags3 & tt->wif3_flags ) == tt->wif3_flags) ) {
found_something = true;
}
}
if( ( ( tt->sif_flags != 0 ) || ( tt->sif2_flags != 0 ) ) && (ptr->type == OBJ_SHIP) ) {
if( ( (Ship_info[Ships[ptr->instance].ship_info_index].flags & tt->sif_flags) == tt->sif_flags)
&& ( (Ship_info[Ships[ptr->instance].ship_info_index].flags2 & tt->sif2_flags) == tt->sif2_flags) ) {
found_something = true;
if( ( tt->sif_flags.any_set() && (ptr->type == OBJ_SHIP) ) ) {
if( (Ship_info[Ships[ptr->instance].ship_info_index].flags & tt->sif_flags) == tt->sif_flags)
{
found_something = true;
}
}
if((tt->obj_flags != 0) && !((ptr->flags & tt->obj_flags) == tt->obj_flags)) {
if ((tt->obj_flags.any_set()) && !((ptr->flags & tt->obj_flags) == tt->obj_flags)) {
found_something = true;
}
@@ -1209,7 +1210,7 @@ int find_turret_enemy(ship_subsys *turret_subsys, int objnum, vec3d *tpos, vec3d
if (Objects[target_objnum].signature == aip->target_signature) {
if (iff_matches_mask(Ships[Objects[target_objnum].instance].team, enemy_team_mask)) {
if ( !(Objects[target_objnum].flags & OF_PROTECTED) ) { // check this flag as well
if ( !(Objects[target_objnum].flags[Object::Object_Flags::Protected]) ) { // check this flag as well
// nprintf(("AI", "Frame %i: Object %i resuming goal of object %i\n", AI_FrameCount, objnum, target_objnum));
return target_objnum;
}
@@ -1224,8 +1225,8 @@ int find_turret_enemy(ship_subsys *turret_subsys, int objnum, vec3d *tpos, vec3d
if ((frand() < 0.8f) && (aip->target_objnum != -1) && Use_parent_target) {
//check if aip->target_objnum is valid target
int target_flags = Objects[aip->target_objnum].flags;
if ( target_flags & OF_PROTECTED ) {
auto target_flags = Objects[aip->target_objnum].flags;
if ( target_flags[Object::Object_Flags::Protected] ) {
// AL 2-27-98: why is a protected ship being targeted?
set_target_objnum(aip, -1);
return -1;
@@ -1234,15 +1235,15 @@ int find_turret_enemy(ship_subsys *turret_subsys, int objnum, vec3d *tpos, vec3d
// maybe use ship target_objnum if valid for turret
// check for beam weapon and beam protected, etc.
bool skip = false;
if ( (target_flags & OF_BEAM_PROTECTED) && beam_flag ) skip = true;
else if ( (target_flags & OF_FLAK_PROTECTED) && flak_flag ) skip = true;
else if ( (target_flags & OF_LASER_PROTECTED) && laser_flag ) skip = true;
else if ( (target_flags & OF_MISSILE_PROTECTED) && missile_flag ) skip = true;
if ( target_flags[Object::Object_Flags::Beam_protected] && beam_flag ) skip = true;
else if ( target_flags[Object::Object_Flags::Flak_protected] && flak_flag ) skip = true;
else if ( target_flags[Object::Object_Flags::Laser_protected] && laser_flag ) skip = true;
else if ( target_flags[Object::Object_Flags::Missile_protected] && missile_flag) skip = true;
if (!skip) {
if ( Objects[aip->target_objnum].type == OBJ_SHIP ) {
// check for huge weapon and huge ship
if ( !big_only_flag || (Ship_info[Ships[Objects[aip->target_objnum].instance].ship_info_index].flags & (SIF_BIG_SHIP|SIF_HUGE_SHIP)) ) {
if ( !big_only_flag || (Ship_info[Ships[Objects[aip->target_objnum].instance].ship_info_index].is_big_or_huge()) ) {
// check for tagged only and tagged ship
if ( tagged_only_flag && ship_is_tagged(&Objects[aip->target_objnum]) ) {
// select new target if aip->target_objnum is out of field of view
@@ -1253,7 +1254,7 @@ int find_turret_enemy(ship_subsys *turret_subsys, int objnum, vec3d *tpos, vec3d
in_fov = turret_fov_test(turret_subsys, tvec, &v2e);
if (turret_subsys->flags & SSF_FOV_EDGE_CHECK) {
if (turret_subsys->flags[Ship::Subsystem_Flags::FOV_edge_check]) {
if (in_fov == false)
if (object_in_turret_fov(&Objects[aip->target_objnum], turret_subsys, tvec, tpos, dist + Objects[aip->target_objnum].radius))
in_fov = true;
@@ -1272,12 +1273,12 @@ int find_turret_enemy(ship_subsys *turret_subsys, int objnum, vec3d *tpos, vec3d
enemy_objnum = get_nearest_turret_objnum(objnum, turret_subsys, enemy_team_mask, tpos, tvec, current_enemy, big_only_flag, small_only_flag, tagged_only_flag, beam_flag, flak_flag, laser_flag, missile_flag);
if ( enemy_objnum >= 0 ) {
Assert( !((Objects[enemy_objnum].flags & OF_BEAM_PROTECTED) && beam_flag) );
Assert( !((Objects[enemy_objnum].flags & OF_FLAK_PROTECTED) && flak_flag) );
Assert( !((Objects[enemy_objnum].flags & OF_LASER_PROTECTED) && laser_flag) );
Assert( !((Objects[enemy_objnum].flags & OF_MISSILE_PROTECTED) && missile_flag) );
Assert( !((Objects[enemy_objnum].flags[Object::Object_Flags::Beam_protected]) && beam_flag) );
Assert( !((Objects[enemy_objnum].flags[Object::Object_Flags::Flak_protected]) && flak_flag) );
Assert( !((Objects[enemy_objnum].flags[Object::Object_Flags::Laser_protected]) && laser_flag) );
Assert( !((Objects[enemy_objnum].flags[Object::Object_Flags::Missile_protected]) && missile_flag) );
if ( Objects[enemy_objnum].flags & OF_PROTECTED ) {
if ( Objects[enemy_objnum].flags[Object::Object_Flags::Protected] ) {
Int3();
enemy_objnum = aip->target_objnum;
}
@@ -1360,11 +1361,11 @@ void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos
turret_ai_update_aim(&Ai_info[Ships[ssp->parent_objnum].ai_index], &Objects[ssp->turret_enemy_objnum], ssp);
if ((ssp->targeted_subsys != nullptr) && !(ssp->flags & SSF_NO_SS_TARGETING)) {
if ((ssp->targeted_subsys != nullptr) && !(ssp->flags[Ship::Subsystem_Flags::No_SS_targeting])) {
vm_vec_unrotate(&enemy_point, &ssp->targeted_subsys->system_info->pnt, &Objects[ssp->turret_enemy_objnum].orient);
vm_vec_add2(&enemy_point, &ssp->last_aim_enemy_pos);
} else {
if ((lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) {
if ((lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].is_big_or_huge())) {
vm_vec_unrotate(&turret_norm, &tp->turret_norm, &objp->orient);
ai_big_pick_attack_point_turret(lep, ssp, &tmp_pos, &turret_norm, &enemy_point, MIN(wip->max_speed * wip->lifetime, wip->weapon_range), tp->turret_fov);
}
@@ -1456,13 +1457,13 @@ int aifft_rotate_turret(ship *shipp, int parent_objnum, ship_subsys *ss, object
//Figure out what point on the ship we want to point the gun at, and store the global location
//in enemy_point.
vec3d enemy_point;
if ((ss->targeted_subsys != NULL) && !(ss->flags & SSF_NO_SS_TARGETING)) {
if ((ss->targeted_subsys != NULL) && !(ss->flags[Ship::Subsystem_Flags::No_SS_targeting])) {
if (ss->turret_enemy_objnum != -1) {
vm_vec_unrotate(&enemy_point, &ss->targeted_subsys->system_info->pnt, &Objects[ss->turret_enemy_objnum].orient);
vm_vec_add2(&enemy_point, &ss->last_aim_enemy_pos);
}
} else {
if ((lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) {
if ((lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].is_big_or_huge())) {
ai_big_pick_attack_point_turret(lep, ss, &gun_pos, &gun_vec, &enemy_point, tp->turret_fov, MIN(wip->max_speed * wip->lifetime, wip->weapon_range));
} else {
enemy_point = ss->last_aim_enemy_pos;
@@ -1496,7 +1497,7 @@ int aifft_rotate_turret(ship *shipp, int parent_objnum, ship_subsys *ss, object
in_fov = turret_fov_test(ss, gvec, &v2e);
if (ss->flags & SSF_FOV_EDGE_CHECK) {
if (ss->flags[Ship::Subsystem_Flags::FOV_edge_check]) {
if (in_fov == false)
in_fov = is_object_radius_in_turret_fov(&Objects[ss->turret_enemy_objnum], ss, gvec, &gun_pos, &v2e, predicted_enemy_pos, 0.0f);
}
@@ -1616,7 +1617,7 @@ ship_subsys *aifft_find_turret_subsys(object *objp, ship_subsys *ssp, object *en
vm_vec_add2(&abs_gun_pos, &objp->pos);
// Only pick a turret to attack on large ships.
if (!(esip->flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)))
if (!esip->is_big_or_huge())
return best_subsysp;
// Make sure big or huge ship *actually* has subsystems (ie, knossos)
@@ -1868,22 +1869,22 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
object *tobjp = &Objects[turret->turret_enemy_objnum];
// should not get this far. check if ship is protected from beam and weapon is type beam
if ( (wip->wi_flags & WIF_BEAM) && (tobjp->flags & OF_BEAM_PROTECTED) ) {
if ( (wip->wi_flags & WIF_BEAM) && (tobjp->flags[Object::Object_Flags::Beam_protected]) ) {
Int3();
return 0;
}
// should not get this far. check if ship is protected from flak and weapon is type flak
else if ( (wip->wi_flags & WIF_FLAK) && (tobjp->flags & OF_FLAK_PROTECTED) ) {
else if ( (wip->wi_flags & WIF_FLAK) && (tobjp->flags[Object::Object_Flags::Flak_protected]) ) {
Int3();
return 0;
}
// should not get this far. check if ship is protected from laser and weapon is type laser
else if ( (wip->subtype == WP_LASER) && (tobjp->flags & OF_LASER_PROTECTED) ) {
else if ( (wip->subtype == WP_LASER) && (tobjp->flags[Object::Object_Flags::Laser_protected]) ) {
Int3();
return 0;
}
// should not get this far. check if ship is protected from missile and weapon is type missile
else if ( (wip->subtype == WP_MISSILE) && (tobjp->flags & OF_MISSILE_PROTECTED) ) {
else if ( (wip->subtype == WP_MISSILE) && (tobjp->flags[Object::Object_Flags::Missile_protected]) ) {
Int3();
return 0;
}
@@ -1933,7 +1934,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
Script_system.RemHookVars(4, "Ship", "Weapon", "Beam", "Target");
}
turret->flags |= SSF_HAS_FIRED; //set fired flag for scripting -nike
turret->flags.set(Ship::Subsystem_Flags::Has_fired); //set fired flag for scripting -nike
return true;
}
// don't fire swam, but set up swarm info instead
@@ -1956,7 +1957,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
} else {
turret_swarm_set_up_info(parent_objnum, turret, wip, turret->turret_next_fire_pos);
turret->flags |= SSF_HAS_FIRED; //set fired flag for scripting -nike
turret->flags.set(Ship::Subsystem_Flags::Has_fired); //set fired flag for scripting -nike
return true;
}
}
@@ -2105,7 +2106,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
if ( wip->launch_snd != -1 ) {
// Don't play turret firing sound if turret sits on player ship... it gets annoying.
if ( parent_objnum != OBJ_INDEX(Player_obj) || (turret->flags & SSF_PLAY_SOUND_FOR_PLAYER) ) {
if ( parent_objnum != OBJ_INDEX(Player_obj) || (turret->flags[Ship::Subsystem_Flags::Play_sound_for_player]) ) {
snd_play_3d( &Snds[wip->launch_snd], turret_pos, &View_position );
}
}
@@ -2126,7 +2127,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
turret->turret_next_fire_stamp = timestamp((int) wait);
}
turret->flags |= SSF_HAS_FIRED; //set has fired flag for scriptng - nuke
turret->flags.set(Ship::Subsystem_Flags::Has_fired); //set has fired flag for scriptng - nuke
//Fire animation stuff
model_anim_start_type(turret, TRIGGER_TYPE_TURRET_FIRED, ANIMATION_SUBTYPE_ALL, 1);
@@ -2442,13 +2443,13 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
if ( lep->type != OBJ_SHIP ) {
continue;
}
if ( !(Ship_info[Ships[lep->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) ) {
if ( !(Ship_info[Ships[lep->instance].ship_info_index].is_big_or_huge()) ) {
continue;
}
}
if ( wip->wi_flags2 & WIF2_SMALL_ONLY ) {
if ( (lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) ) {
if ( (lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].is_big_or_huge()) ) {
continue;
}
}
@@ -2457,32 +2458,32 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
if (lep->type == OBJ_SHIP) {
// Check if we're targeting a protected ship
if (lep->flags & OF_PROTECTED) {
if (lep->flags[Object::Object_Flags::Protected]) {
ss->turret_enemy_objnum = -1;
ss->turret_time_enemy_in_range = 0.0f;
continue;
}
// Check if we're targeting a beam protected ship with a beam weapon
if ( (lep->flags & OF_BEAM_PROTECTED) && (wip->wi_flags & WIF_BEAM) ) {
if ( (lep->flags[Object::Object_Flags::Beam_protected]) && (wip->wi_flags & WIF_BEAM) ) {
ss->turret_enemy_objnum = -1;
ss->turret_time_enemy_in_range = 0.0f;
continue;
}
// Check if we're targeting a flak protected ship with a flak weapon
else if ( (lep->flags & OF_FLAK_PROTECTED) && (wip->wi_flags & WIF_FLAK) ) {
else if ( (lep->flags[Object::Object_Flags::Flak_protected]) && (wip->wi_flags & WIF_FLAK) ) {
ss->turret_enemy_objnum = -1;
ss->turret_time_enemy_in_range = 0.0f;
continue;
}
// Check if we're targeting a laser protected ship with a laser weapon
else if ( (lep->flags & OF_LASER_PROTECTED) && (wip->subtype == WP_LASER) ) {
else if ( (lep->flags[Object::Object_Flags::Laser_protected]) && (wip->subtype == WP_LASER) ) {
ss->turret_enemy_objnum = -1;
ss->turret_time_enemy_in_range = 0.0f;
continue;
}
// Check if we're targeting a missile protected ship with a missile weapon
else if ( (lep->flags & OF_MISSILE_PROTECTED) && (wip->subtype == WP_MISSILE) ) {
else if ( (lep->flags[Object::Object_Flags::Missile_protected]) && (wip->subtype == WP_MISSILE) ) {
ss->turret_enemy_objnum = -1;
ss->turret_time_enemy_in_range = 0.0f;
continue;
@@ -2536,7 +2537,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
if (ss->turret_enemy_objnum != -1) {
float dot = 1.0f;
lep = &Objects[ss->turret_enemy_objnum];
if (( lep->type == OBJ_SHIP ) && !(ss->flags & SSF_NO_SS_TARGETING)) {
if (( lep->type == OBJ_SHIP ) && !(ss->flags[Ship::Subsystem_Flags::No_SS_targeting])) {
ss->targeted_subsys = aifft_find_turret_subsys(objp, ss, lep, &dot);
}
ss->turret_next_enemy_check_stamp = timestamp((int) (MAX(dot, 0.5f)*2000.0f) + 1000);
@@ -2563,7 +2564,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
return;
}
if (Objects[ss->turret_enemy_objnum].flags & OF_PROTECTED) {
if (Objects[ss->turret_enemy_objnum].flags[Object::Object_Flags::Protected]) {
// This can happen if the enemy was selected before it became protected.
ss->turret_enemy_objnum = -1;
return;
+37 -23
View File
@@ -107,7 +107,7 @@ int asteroid_obj_list_add(int objnum)
int index;
asteroid *cur_asteroid = &Asteroids[Objects[objnum].instance];
index = cur_asteroid - Asteroids;
index = (int)(cur_asteroid - Asteroids);
Assert(index >= 0 && index < MAX_ASTEROID_OBJS);
Assert(!(Asteroid_objs[index].flags & ASTEROID_OBJ_USED));
@@ -320,8 +320,12 @@ object *asteroid_create(asteroid_field *asfieldp, int asteroid_type, int asteroi
}
vm_angles_2_matrix(&orient, &angs);
objnum = obj_create( OBJ_ASTEROID, -1, n, &orient, &pos, radius, OF_RENDERS | OF_PHYSICS | OF_COLLIDES);
flagset<Object::Object_Flags> asteroid_default_flagset;
asteroid_default_flagset += Object::Object_Flags::Renders;
asteroid_default_flagset += Object::Object_Flags::Physics;
asteroid_default_flagset += Object::Object_Flags::Collides;
objnum = obj_create(OBJ_ASTEROID, -1, n, &orient, &pos, radius, asteroid_default_flagset);
if ( (objnum == -1) || (objnum >= MAX_OBJECTS) ) {
mprintf(("Couldn't create asteroid -- out of object slots\n"));
@@ -804,7 +808,7 @@ void maybe_throw_asteroid(int count)
// if asteroid is inside inner bound, kill it
if (asteroid_in_inner_bound(&Asteroid_field, &objp->pos, 0.0f)) {
objp->flags |= OF_SHOULD_BE_DEAD;
objp->flags.set(Object::Object_Flags::Should_be_dead);
} else {
Asteroids[objp->instance].target_objnum = so->objnum;
@@ -870,7 +874,7 @@ void asteroid_maybe_reposition(object *objp, asteroid_field *asfieldp)
if ( (dot < 0.7f) || (dist > asfieldp->bound_rad) ) {
if (Num_asteroids > MAX_ASTEROIDS-10) {
objp->flags |= OF_SHOULD_BE_DEAD;
objp->flags.set(Object::Object_Flags::Should_be_dead);
} else {
// check to ensure player won't see asteroid appear either
asteroid_wrap_pos(objp, asfieldp);
@@ -915,7 +919,7 @@ void asteroid_process_pre( object *objp )
}
}
int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos, collision_info_struct *asteroid_hit_info)
int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos, collision_info_struct *asteroid_hit_info, vec3d* hitnormal)
{
if (!Asteroids_enabled) {
return 0;
@@ -947,8 +951,18 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
mc.flags = (MC_CHECK_MODEL);
if (model_collide(&mc))
{
*hitpos = mc.hit_point_world;
if (hitnormal)
{
vec3d normal;
model_find_world_dir(&normal, &mc.hit_normal, mc.model_num, mc.hit_submodel, mc.orient);
*hitnormal = normal;
}
}
return mc.num_hits;
}
@@ -1326,7 +1340,7 @@ void asteroid_do_area_effect(object *asteroid_objp)
ship_objp = &Objects[so->objnum];
// don't blast navbuoys
if ( ship_get_SIF(ship_objp->instance) & SIF_NAVBUOY ) {
if ( ship_get_SIF(ship_objp->instance)[Ship::Info_Flags::Navbuoy] ) {
continue;
}
@@ -1353,7 +1367,7 @@ void asteroid_hit( object * pasteroid_obj, object * other_obj, vec3d * hitpos, f
asp = &Asteroids[pasteroid_obj->instance];
if (pasteroid_obj->flags & OF_SHOULD_BE_DEAD){
if (pasteroid_obj->flags[Object::Object_Flags::Should_be_dead]){
return;
}
@@ -1388,8 +1402,8 @@ void asteroid_hit( object * pasteroid_obj, object * other_obj, vec3d * hitpos, f
weapon_info *wip;
wip = &Weapon_info[Weapons[other_obj->instance].weapon_info_index];
// If the weapon didn't play any impact animation, play custom asteroid impact animation
if ( wip->impact_weapon_expl_index < 0 ) {
particle_create( hitpos, &vmd_zero_vector, 0.0f, Asteroid_impact_explosion_radius, PARTICLE_BITMAP, Asteroid_impact_explosion_ani );
if ( wip->impact_weapon_expl_effect < 0 ) {
particle::create( hitpos, &vmd_zero_vector, 0.0f, Asteroid_impact_explosion_radius, particle::PARTICLE_BITMAP, Asteroid_impact_explosion_ani );
}
}
}
@@ -1409,7 +1423,7 @@ void asteroid_level_close()
if (Asteroids[i].flags & AF_USED) {
Asteroids[i].flags &= ~AF_USED;
Assert(Asteroids[i].objnum >=0 && Asteroids[i].objnum < MAX_OBJECTS);
Objects[Asteroids[i].objnum].flags |= OF_SHOULD_BE_DEAD;
Objects[Asteroids[i].objnum].flags.set(Object::Object_Flags::Should_be_dead);
}
}
@@ -1474,7 +1488,7 @@ void asteroid_maybe_break_up(object *pasteroid_obj)
Script_system.SetHookObject("Self", pasteroid_obj);
if(!Script_system.IsConditionOverride(CHA_DEATH, pasteroid_obj))
{
pasteroid_obj->flags |= OF_SHOULD_BE_DEAD;
pasteroid_obj->flags.set(Object::Object_Flags::Should_be_dead);
// multiplayer clients won't go through the following code. asteroid_sub_create will send
// a create packet to the client in the above named function
@@ -1531,8 +1545,8 @@ void asteroid_maybe_break_up(object *pasteroid_obj)
random_shuffle(roids_to_create.begin(), roids_to_create.end());
int total_roids = roids_to_create.size();
for (int i = 0; i < total_roids; i++) {
size_t total_roids = roids_to_create.size();
for (size_t i = 0; i < total_roids; i++) {
vec3d dir_vec,final_vec;
vec3d parent_vel,hit_rel_vec;
@@ -1659,11 +1673,11 @@ int asteroid_will_collide(object *pasteroid_obj, object *escort_objp)
*/
int asteroid_valid_ship_to_warn_collide(ship *shipp)
{
if ( !(Ship_info[shipp->ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) ) {
if ( !(Ship_info[shipp->ship_info_index].is_big_or_huge()) ) {
return 0;
}
if ( shipp->flags & (SF_DYING|SF_DEPART_WARP) ) {
if ( shipp->flags[Ship::Ship_Flags::Dying] || shipp->flags[Ship::Ship_Flags::Depart_warp] ) {
return 0;
}
@@ -1915,8 +1929,8 @@ void asteroid_parse_tbl()
required_string("#Asteroid Types");
int tally = 0;
int max_asteroids =
size_t tally = 0;
size_t max_asteroids =
NUM_DEBRIS_SIZES + Species_info.size() * NUM_DEBRIS_SIZES;
#ifndef NDEBUG
@@ -1930,7 +1944,7 @@ void asteroid_parse_tbl()
asteroid_parse_section(&new_asteroid);
int species = tally / NUM_DEBRIS_SIZES;
size_t species = tally / NUM_DEBRIS_SIZES;
if (tally >= max_asteroids)
{
#ifdef NDEBUG
@@ -1967,7 +1981,7 @@ void asteroid_parse_tbl()
default:
Error(LOCATION, "Get a coder! Math has broken!\n"
"Important numbers:\n"
"\ttally: %d\n"
"\ttally: " SIZE_T_ARG "\n"
"\tNUM_DEBRIS_SIZES: %d\n",
tally, NUM_DEBRIS_SIZES
);
@@ -1992,9 +2006,9 @@ void asteroid_parse_tbl()
}
#endif
Error(LOCATION,
"Found %d asteroids/debris when %d expected\n\n"
"Found " SIZE_T_ARG " asteroids/debris when " SIZE_T_ARG " expected\n\n"
"<Number expected> = <Number of species> * %d + %d generic asteroids\n"
"%d = " SIZE_T_ARG "*%d + %d\n\n"
SIZE_T_ARG " = " SIZE_T_ARG "*%d + %d\n\n"
#ifdef NDEBUG
"Run a debug build to see a list of all parsed asteroids\n",
#else
@@ -2085,7 +2099,7 @@ int set_asteroid_throw_objnum()
ship_objp = &Objects[so->objnum];
float radius = ship_objp->radius*2.0f;
if (Ship_info[Ships[ship_objp->instance].ship_info_index].flags & (SIF_HUGE_SHIP | SIF_BIG_SHIP)) {
if (Ship_info[Ships[ship_objp->instance].ship_info_index].is_big_or_huge()) {
if (ship_objp->pos.xyz.x + radius > Asteroid_field.min_bound.xyz.x)
if (ship_objp->pos.xyz.y + radius > Asteroid_field.min_bound.xyz.y)
if (ship_objp->pos.xyz.z + radius > Asteroid_field.min_bound.xyz.z)
+1 -1
View File
@@ -156,7 +156,7 @@ void asteroid_render(object * obj, draw_list *scene);
void asteroid_delete( object *asteroid_objp );
void asteroid_process_pre( object *asteroid_objp );
void asteroid_process_post( object *asteroid_objp);
int asteroid_check_collision( object *asteroid_objp, object * other_obj, vec3d * hitpos, collision_info_struct *asteroid_hit_info=NULL );
int asteroid_check_collision( object *asteroid_objp, object * other_obj, vec3d * hitpos, collision_info_struct *asteroid_hit_info=NULL, vec3d* hitnormal=NULL );
void asteroid_hit( object *pasteroid_objp, object *other_objp, vec3d *hitpos, float damage );
int asteroid_count();
int asteroid_collide_objnum(object *asteroid_objp);
+42 -39
View File
@@ -178,7 +178,7 @@ bool CanAutopilot(vec3d targetPos, bool send_msg)
object *other_objp = &Objects[so->objnum];
// attacks player?
if (iff_x_attacks_y(obj_team(other_objp), obj_team(Player_obj))
&& !(Ship_info[Ships[other_objp->instance].ship_info_index].flags & SIF_CARGO)) // ignore cargo
&& !(Ship_info[Ships[other_objp->instance].ship_info_index].flags[Ship::Info_Flags::Cargo])) // ignore cargo
{
// Cannot autopilot if enemy within AutopilotMinEnemyDistance meters
if (vm_vec_dist_quick(&targetPos, &other_objp->pos) < AutopilotMinEnemyDistance) {
@@ -233,7 +233,7 @@ bool StartAutopilot()
// If the support ship is doing something then tell the user such.
for ( object *objp = GET_FIRST(&obj_used_list); objp !=END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp) )
{
if ((objp->type == OBJ_SHIP) && !(objp->flags & OF_SHOULD_BE_DEAD))
if ((objp->type == OBJ_SHIP) && !(objp->flags[Object::Object_Flags::Should_be_dead]))
{
Assertion((objp->instance >= 0) && (objp->instance < MAX_SHIPS),
"objp does not have a valid pointer to a ship. Pointer is %d, which is smaller than 0 or bigger than %d",
@@ -248,11 +248,11 @@ bool StartAutopilot()
shipp->ship_name, shipp->ship_info_index, static_cast<int>(Ship_info.size()));
ship_info *sip = &Ship_info[shipp->ship_info_index];
if ( !(sip->flags & SIF_SUPPORT) )
if ( !(sip->flags[Ship::Info_Flags::Support]) )
continue;
// don't deal with dying or departing support ships
if ( shipp->flags & (SF_DYING | SF_DEPARTING) )
if ( shipp->is_dying_or_departing() )
continue;
Assert(shipp->ai_index != -1);
@@ -286,7 +286,7 @@ bool StartAutopilot()
Autopilot_flight_leader = Player_obj;
}
if (The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS)
if (The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics])
LockAPConv = timestamp(); // lock convergence instantly
else
LockAPConv = timestamp(3000); // 3 seconds before we lock convergence
@@ -325,7 +325,7 @@ bool StartAutopilot()
// instantly turn player toward tpos
if (The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS)
if (The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics])
{
vm_vec_sub(&norm1, Navs[CurrentNav].GetPosition(), &Player_obj->pos);
vm_vector_2_matrix(&Player_obj->orient, &norm1, NULL, NULL);
@@ -334,7 +334,7 @@ bool StartAutopilot()
for (i = 0; i < MAX_SHIPS; i++)
{
if (Ships[i].objnum != -1 &&
(Ships[i].flags2 & SF2_NAVPOINT_CARRY ||
(Ships[i].flags[Ship::Ship_Flags::Navpoint_carry] ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY)
)
)
@@ -345,7 +345,7 @@ bool StartAutopilot()
}
// damp speed_cap to 90% of actual -- to make sure ships stay in formation
if (The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS)
if (The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics])
speed_cap = 0.90f * speed_cap;
if ( speed_cap < 1.0f ) {
@@ -367,28 +367,27 @@ bool StartAutopilot()
for (i = 0; i < MAX_SHIPS; i++)
{
if (Ships[i].objnum != -1 &&
(Ships[i].flags2 & SF2_NAVPOINT_CARRY ||
(Ships[i].flags[Ship::Ship_Flags::Navpoint_carry] ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY)
)
)
{
// do we have capital ships in the area?
if (Ship_info[Ships[i].ship_info_index].flags
& ( SIF_CRUISER | SIF_CAPITAL | SIF_SUPERCAP | SIF_CORVETTE | SIF_AWACS | SIF_GAS_MINER | SIF_FREIGHTER | SIF_TRANSPORT))
if (Ship_info[Ships[i].ship_info_index].is_big_ship() || Ship_info[Ships[i].ship_info_index].flags[Ship::Info_Flags::Capital] || Ship_info[Ships[i].ship_info_index].flags[Ship::Info_Flags::Supercap])
{
capshipPresent = true;
capIndexes.push_back(i);
// ok.. what size class
if (Ship_info[Ships[i].ship_info_index].flags & (SIF_CAPITAL | SIF_SUPERCAP))
{
capship_counts[0]++;
if (capship_spreads[0] < Objects[Ships[i].objnum].radius)
capship_spreads[0] = Objects[Ships[i].objnum].radius;
}
else if (Ship_info[Ships[i].ship_info_index].flags & (SIF_CORVETTE))
{
if (Ship_info[Ships[i].ship_info_index].flags[Ship::Info_Flags::Capital] || Ship_info[Ships[i].ship_info_index].flags[Ship::Info_Flags::Supercap])
{
capship_counts[0]++;
if (capship_spreads[0] < Objects[Ships[i].objnum].radius)
capship_spreads[0] = Objects[Ships[i].objnum].radius;
}
else if (Ship_info[Ships[i].ship_info_index].flags[Ship::Info_Flags::Corvette])
{
capship_counts[1]++;
if (capship_spreads[1] < Objects[Ships[i].objnum].radius)
capship_spreads[1] = Objects[Ships[i].objnum].radius;
@@ -416,14 +415,14 @@ bool StartAutopilot()
radius = Objects[Ships[i].objnum].radius;
}
if (The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS)
if (The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics])
{// instantly turn the ship to match the direction player is looking
//vm_vec_sub(&norm1, Navs[CurrentNav].GetPosition(), &Player_obj->pos);
vm_vector_2_matrix(&Objects[Ships[i].objnum].orient, &norm1, NULL, NULL);
}
// snap wings into formation
if (The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS && // only if using cinematics
if (The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics] && // only if using cinematics
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY) // only if in a wing
&& Autopilot_flight_leader != &Objects[Ships[i].objnum]) //only if not flight leader's object
{
@@ -470,8 +469,10 @@ bool StartAutopilot()
}
}
// lock primary and secondary weapons
if ( LockWeaponsDuringAutopilot )
Ships[i].flags2 |= (SF2_PRIMARIES_LOCKED | SF2_SECONDARIES_LOCKED);
if (LockWeaponsDuringAutopilot) {
Ships[i].flags.set(Ship::Ship_Flags::Primaries_locked);
Ships[i].flags.set(Ship::Ship_Flags::Secondaries_locked);
}
// clear the ship goals and cap the waypoint speed
ai_clear_ship_goals(&Ai_info[Ships[i].ai_index]);
@@ -479,7 +480,7 @@ bool StartAutopilot()
// if they're not part of a wing set their goal
if (Ships[i].wingnum == -1 || The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS)
if (Ships[i].wingnum == -1 || The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics])
{
if (Navs[CurrentNav].flags & NP_WAYPOINT)
{
@@ -496,7 +497,7 @@ bool StartAutopilot()
}
// assign wing goals
if (!(The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS))
if (!(The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics]))
{
for (i = 0; i < MAX_WINGS; i++)
{
@@ -538,7 +539,7 @@ bool StartAutopilot()
{
if (Ships[i].objnum != -1)
{
if (Ships[i].flags2 & SF2_NAVPOINT_CARRY ||
if (Ships[i].flags[Ship::Ship_Flags::Navpoint_carry] ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY))
for (j = 0; j < MAX_AI_GOALS; j++)
{
@@ -557,7 +558,7 @@ bool StartAutopilot()
start_dist = DistanceTo(CurrentNav);
// ----------------------------- setup cinematic -----------------------------
if (The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS)
if (The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics])
{
if (capshipPresent)
{
@@ -570,7 +571,7 @@ bool StartAutopilot()
vm_vec_add(&front, &Autopilot_flight_leader->orient.vec.fvec, &zero);
vm_vec_add(&up, &Autopilot_flight_leader->orient.vec.uvec, &zero);
vm_vec_add(&offset, &zero, &zero);
if (Ship_info[Ships[*idx].ship_info_index].flags & (SIF_CAPITAL | SIF_SUPERCAP))
if (Ship_info[Ships[*idx].ship_info_index].flags[Ship::Info_Flags::Capital] || Ship_info[Ships[*idx].ship_info_index].flags[Ship::Info_Flags::Supercap])
{
//0 - below - three lines of position
@@ -604,7 +605,7 @@ bool StartAutopilot()
capship_placed[0]++;
}
else if (Ship_info[Ships[*idx].ship_info_index].flags & SIF_CORVETTE)
else if (Ship_info[Ships[*idx].ship_info_index].flags[Ship::Info_Flags::Corvette])
{
//1 above - 3 lines of position
// front/back to zero
@@ -913,14 +914,16 @@ void EndAutoPilot()
{
if (Ships[i].objnum != -1 &&
(
Ships[i].flags2 & SF2_NAVPOINT_CARRY ||
Ships[i].flags[Ship::Ship_Flags::Navpoint_carry] ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY )
)
)
{
//unlock their weaponry
if ( LockWeaponsDuringAutopilot )
Ships[i].flags2 &= ~(SF2_PRIMARIES_LOCKED | SF2_SECONDARIES_LOCKED);
if (LockWeaponsDuringAutopilot) {
Ships[i].flags.remove(Ship::Ship_Flags::Primaries_locked);
Ships[i].flags.remove(Ship::Ship_Flags::Secondaries_locked);
}
Ai_info[Ships[i].ai_index].waypoint_speed_cap = -1; // uncap their speed
Ai_info[Ships[i].ai_index].mode = AIM_NONE; // make AI re-evaluate current ship mode
@@ -955,7 +958,7 @@ void EndAutoPilot()
}
// un-assign wing goals
if ( !(The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS) )
if ( !(The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics]) )
{
for (i = 0; i < MAX_WINGS; i++)
{
@@ -1041,7 +1044,7 @@ void nav_warp(bool prewarp=false)
for (int i = 0; i < MAX_SHIPS; i++)
{
if (Ships[i].objnum != -1
&& (Ships[i].flags2 & SF2_NAVPOINT_CARRY
&& (Ships[i].flags[Ship::Ship_Flags::Navpoint_carry]
|| (Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY)))
{
vm_vec_add(&Objects[Ships[i].objnum].pos, &Objects[Ships[i].objnum].pos, &targetPos);
@@ -1069,7 +1072,7 @@ void NavSystem_Do()
{
if (AutoPilotEngaged)
{
if (The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS)
if (The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics])
{
camera *cam = nav_get_set_camera();
if (CinematicStarted)
@@ -1148,7 +1151,7 @@ void NavSystem_Do()
}
// ramp time compression - only if not using cinematics
if (AutoPilotEngaged && !(The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS))
if (AutoPilotEngaged && !(The_mission.flags[Mission::Mission_Flags::Use_ap_cinematics]))
{
int dstfrm_start = start_dist - DistanceTo(CurrentNav);
@@ -1193,14 +1196,14 @@ void NavSystem_Do()
*/
for (int i = 0; i < MAX_SHIPS; i++)
{
if (Ships[i].objnum != -1 && Ships[i].flags2 & SF2_NAVPOINT_NEEDSLINK)
if (Ships[i].objnum != -1 && Ships[i].flags[Ship::Ship_Flags::Navpoint_needslink])
{
object *other_objp = &Objects[Ships[i].objnum];
if (vm_vec_dist_quick(&Player_obj->pos, &other_objp->pos) < (NavLinkDistance + other_objp->radius))
{
Ships[i].flags2 &= ~SF2_NAVPOINT_NEEDSLINK;
Ships[i].flags2 |= SF2_NAVPOINT_CARRY;
Ships[i].flags.remove(Ship::Ship_Flags::Navpoint_needslink);
Ships[i].flags.set(Ship::Ship_Flags::Navpoint_carry);
send_autopilot_msgID(NP_MSG_MISC_LINKED);
}
+1 -1
View File
@@ -84,7 +84,7 @@ struct bitmap_entry {
// bookeeping
ubyte used_last_frame; // If set, then it was used last frame
ubyte used_this_frame; // If set, then it was used this frame
int data_size; // How much data this bitmap uses
size_t data_size; // How much data this bitmap uses
int used_count; // How many times it was accessed
#endif
};
+12 -13
View File
@@ -65,7 +65,7 @@ int HEIGHTMAP = -1;
int MISCMAP = -1;
int AMBIENTMAP = -1;
int bm_texture_ram = 0;
size_t bm_texture_ram = 0;
int Bm_paging = 0;
// Extension type lists
@@ -158,8 +158,8 @@ float bitmap_lookup::get_channel_red(float u, float v)
{
Assert( Bitmap_data != NULL );
CLAMP(u, 0.0, 1.0f);
CLAMP(v, 0.0, 1.0f);
CLAMP(u, 0.0f, 1.0f);
CLAMP(v, 0.0f, 1.0f);
int x = fl2i(map_texture_address(u) * (Width-1));
int y = fl2i(map_texture_address(v) * (Height-1));
@@ -1099,7 +1099,7 @@ int bm_is_valid(int handle) {
// c_type = output for an updated BM_TYPE_*
// mm_lvl = number of mipmap levels for the image
// size = size of the data contained in the image
static int bm_load_info(BM_TYPE type, int n, const char *filename, CFILE *img_cfp, int *w, int *h, int *bpp, BM_TYPE *c_type, int *mm_lvl, int *size)
static int bm_load_info(BM_TYPE type, int n, const char *filename, CFILE *img_cfp, int *w, int *h, int *bpp, BM_TYPE *c_type, int *mm_lvl, size_t *size)
{
int dds_ct;
@@ -1194,7 +1194,8 @@ int bm_load(const char *real_filename) {
int i, free_slot = -1;
int w, h, bpp = 8;
int rc = 0;
int bm_size = 0, mm_lvl = 0;
size_t bm_size = 0;
int mm_lvl = 0;
char filename[MAX_FILENAME_LEN];
BM_TYPE type = BM_TYPE_NONE;
BM_TYPE c_type = BM_TYPE_NONE;
@@ -1399,8 +1400,6 @@ static int bm_load_image_data(const char *filename, int handle, int bitmapnum, i
bitmap_entry *be = &bm_bitmaps[bitmapnum];
bitmap *bmp = &be->bm;
Assert(!Is_standalone);
if (bmp->true_bpp > bpp)
true_bpp = bmp->true_bpp;
else
@@ -1505,7 +1504,8 @@ int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *ke
float anim_total_time = 0.0f;
int anim_width = 0, anim_height = 0;
BM_TYPE type = BM_TYPE_NONE, eff_type = BM_TYPE_NONE, c_type = BM_TYPE_NONE;
int bpp = 0, mm_lvl = 0, img_size = 0;
int bpp = 0, mm_lvl = 0;
size_t img_size = 0;
char clean_name[MAX_FILENAME_LEN];
if (!bm_inited)
@@ -1866,7 +1866,7 @@ int bm_load_sub_fast(const char *real_filename, int *handle, int dir_type, bool
int bm_load_sub_slow(const char *real_filename, const int num_ext, const char **ext_list, CFILE **img_cfp, int dir_type) {
char full_path[MAX_PATH];
int size = 0, offset = 0;
size_t size = 0, offset = 0;
int rval = -1;
rval = cf_find_file_location_ext(real_filename, num_ext, ext_list, dir_type, sizeof(full_path) - 1, full_path, &size, &offset, 0);
@@ -2522,10 +2522,10 @@ int bm_make_render_target(int width, int height, int flags) {
return bm_bitmaps[n].handle;
}
void *bm_malloc(int n, int size) {
void *bm_malloc(int n, size_t size) {
Assert((n >= 0) && (n < MAX_BITMAPS));
if (size <= 0)
if (size == 0)
return NULL;
#ifdef BMPMAN_NDEBUG
@@ -3211,10 +3211,9 @@ void bm_unlock(int handle) {
Assert(be->ref_count >= 0); // Trying to unlock data more times than lock was called!!!
}
void bm_update_memory_used(int n, int size)
void bm_update_memory_used(int n, size_t size)
{
Assert( (n >= 0) && (n < MAX_BITMAPS) );
Assert( size >= 0 );
#ifdef BMPMAN_NDEBUG
Assert( bm_bitmaps[n].data_size == 0 );
+3 -3
View File
@@ -112,7 +112,7 @@ struct bitmap
*/
};
extern int bm_texture_ram; //!< how many bytes of textures are used.
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.
@@ -170,14 +170,14 @@ int bm_get_next_handle();
* @note z64 - This function looks fishy. Not only is handle not used in release builds, but bm_bitmaps[handle].size
* and bm_texture_size aren't modified unless this is a debug build
*/
void *bm_malloc(int handle, int size);
void *bm_malloc(int handle, size_t size);
/**
* @brief (DEBUG) Similar to bm_malloc, but only updates how much memory is used
*
* @note z64 - Also fishy (see bm_malloc)
*/
void bm_update_memory_used(int n, int size);
void bm_update_memory_used(int n, size_t size);
class bitmap_lookup {
ubyte *Bitmap_data;
+9 -9
View File
@@ -612,8 +612,8 @@ subtitle::subtitle(int in_x_pos, int in_y_pos, const char* in_text, const char*
int old_fontnum;
if (text_fontnum >= 0)
{
old_fontnum = gr_get_current_fontnum();
gr_set_font(text_fontnum);
old_fontnum = font::get_current_fontnum();
font::set_font(text_fontnum);
}
else
{
@@ -634,7 +634,7 @@ subtitle::subtitle(int in_x_pos, int in_y_pos, const char* in_text, const char*
// restore old font
if (old_fontnum >= 0)
{
gr_set_font(old_fontnum);
font::set_font(old_fontnum);
}
//Get image size
@@ -710,8 +710,8 @@ void subtitle::do_frame(float frametime)
int old_fontnum;
if (text_fontnum >= 0)
{
old_fontnum = gr_get_current_fontnum();
gr_set_font(text_fontnum);
old_fontnum = font::get_current_fontnum();
font::set_font(text_fontnum);
}
else
{
@@ -732,7 +732,7 @@ void subtitle::do_frame(float frametime)
// restore old font
if (old_fontnum >= 0)
{
gr_set_font(old_fontnum);
font::set_font(old_fontnum);
}
if(image_id >= 0)
@@ -824,7 +824,7 @@ camid::camid()
sig = -1;
}
camid::camid(int n_idx, int n_sig)
camid::camid(size_t n_idx, int n_sig)
{
idx = n_idx;
sig = n_sig;
@@ -838,7 +838,7 @@ camera* camid::getCamera()
return Cameras[idx];
}
uint camid::getIndex()
size_t camid::getIndex()
{
return idx;
}
@@ -954,7 +954,7 @@ camid cam_get_current()
return Current_camera;
}
uint cam_get_num()
size_t cam_get_num()
{
return Cameras.size();
}
+1 -1
View File
@@ -166,7 +166,7 @@ void cam_reset_camera();
camid cam_lookup(char *name);
camid cam_get_camera(uint index);
camid cam_get_current();
uint cam_get_num();
size_t cam_get_num();
void get_turret_cam_pos(camera *cam, vec3d *pos);
void get_turret_cam_orient(camera *cam, matrix *ori);
+32 -30
View File
@@ -34,6 +34,7 @@
#include "osapi/osapi.h"
#include "parse/encrypt.h"
#include <limits>
char Cfile_root_dir[CFILE_ROOT_DIRECTORY_LEN] = "";
char Cfile_user_dir[CFILE_ROOT_DIRECTORY_LEN] = "";
@@ -107,7 +108,7 @@ static const char *Cfile_cdrom_dir = NULL;
//
static int cfget_cfile_block();
static CFILE *cf_open_fill_cfblock(const char* source, int line, FILE * fp, int type);
static CFILE *cf_open_packed_cfblock(const char* source, int line, FILE *fp, int type, int offset, int size);
static CFILE *cf_open_packed_cfblock(const char* source, int line, FILE *fp, int type, size_t offset, size_t size);
#if defined _WIN32
static CFILE *cf_open_mapped_fill_cfblock(const char* source, int line, HANDLE hFile, int type);
@@ -183,9 +184,8 @@ static bool cfile_in_root_dir(const char *exe_path)
*/
int cfile_init(const char *exe_dir, const char *cdrom_dir)
{
int i;
encrypt_init(); /* initialize encryption */
// initialize encryption
encrypt_init();
if (cfile_inited) {
return 0;
@@ -195,7 +195,7 @@ int cfile_init(const char *exe_dir, const char *cdrom_dir)
strncpy(buf, exe_dir, CFILE_ROOT_DIRECTORY_LEN - 1);
buf[CFILE_ROOT_DIRECTORY_LEN - 1] = '\0';
i = strlen(buf);
size_t i = strlen(buf);
// are we in a root directory?
if(cfile_in_root_dir(buf)){
@@ -407,7 +407,7 @@ int cfile_flush_dir(int dir_type)
// proceed to delete the files
del_count = 0;
#if defined _WIN32
int find_handle;
intptr_t find_handle;
_finddata_t find;
find_handle = _findfirst( "*", &find );
if (find_handle != -1) {
@@ -459,11 +459,10 @@ int cfile_flush_dir(int dir_type)
// Returns: new filename or filepath with extension.
char *cf_add_ext(const char *filename, const char *ext)
{
int flen, elen;
static char path[MAX_PATH_LEN];
flen = strlen(filename);
elen = strlen(ext);
size_t flen = strlen(filename);
size_t elen = strlen(ext);
Assert(flen < MAX_PATH_LEN);
strcpy_s(path, filename);
if ((flen < 4) || stricmp(path + flen - elen, ext)) {
@@ -515,7 +514,7 @@ int cf_access(const char *filename, int dir_type, int mode)
// If offset equates to boolean true, it was found in a VP and the logic will negate the function return
int cf_exists(const char *filename, int dir_type)
{
int offset = 1;
size_t offset = 1;
if ( (filename == NULL) || !strlen(filename) )
return 0;
@@ -758,7 +757,7 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
//================================================
// Search for file on disk, on cdrom, or in a packfile
int offset, size;
size_t offset, size;
char copy_file_path[MAX_PATH_LEN]; // FIX change in memory from cf_find_file_location
strcpy_s(copy_file_path, file_path);
@@ -819,7 +818,7 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
// returns: success ==> address of CFILE structure
// error ==> NULL
//
CFILE *_cfopen_special(const char* source, int line, const char *file_path, const char *mode, const int size, const int offset, int dir_type)
CFILE *_cfopen_special(const char* source, int line, const char *file_path, const char *mode, const size_t size, const size_t offset, int dir_type)
{
if ( !cfile_inited) {
Int3();
@@ -828,7 +827,6 @@ CFILE *_cfopen_special(const char* source, int line, const char *file_path, cons
Assert( file_path && strlen(file_path) );
Assert( mode != NULL );
Assert( offset >= 0 );
// cfopen_special() only supports reading files, not creating them
if ( strchr(mode, 'w') ) {
@@ -1019,7 +1017,7 @@ static CFILE *cf_open_fill_cfblock(const char* source, int line, FILE *fp, int t
// returns: success ==> ptr to CFILE structure.
// error ==> NULL
//
static CFILE *cf_open_packed_cfblock(const char* source, int line, FILE *fp, int type, int offset, int size)
static CFILE *cf_open_packed_cfblock(const char* source, int line, FILE *fp, int type, size_t offset, size_t size)
{
// Found it in a pack file
int cfile_block_index;
@@ -1388,7 +1386,7 @@ int cfwrite_string(const char *buf, CFILE *file)
if ( (!buf) || (buf && !buf[0]) ) {
return cfwrite_char(0, file);
}
int len = strlen(buf);
int len = (int)strlen(buf);
if(!cfwrite(buf, len, 1, file)){
return 0;
}
@@ -1397,7 +1395,7 @@ int cfwrite_string(const char *buf, CFILE *file)
int cfwrite_string_len(const char *buf, CFILE *file)
{
int len = strlen(buf);
int len = (int)strlen(buf);
if(!cfwrite_int(len, file)){
return 0;
@@ -1423,7 +1421,11 @@ int cfilelength( CFILE * cfile )
Assert(cb->fp != NULL);
// cb->size gets set at cfopen
return cb->size;
// The rest of the code still uses ints, do an overflow check to detect cases where this fails
Assertion(cb->size <= static_cast<size_t>(std::numeric_limits<int>::max()),
"Integer overflow in cfilelength! A file is too large (but I don't know which...).");
return (int) cb->size;
}
// cfwrite() writes to the file
@@ -1468,7 +1470,7 @@ int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile)
Assert( cb->size == filelength(fileno(cb->fp)) );
#endif
return ((int)bytes_written / elsize);
return (int)(bytes_written / elsize);
}
@@ -1649,7 +1651,7 @@ ushort cf_add_chksum_short(ushort seed, ubyte *buffer, int size)
}
// update cur_chksum with the chksum of the new_data of size new_data_size
uint cf_add_chksum_long(uint seed, ubyte *buffer, int size)
uint cf_add_chksum_long(uint seed, ubyte *buffer, size_t size)
{
uint crc;
ubyte *p;
@@ -1741,14 +1743,12 @@ static int cf_chksum_do(CFILE *cfile, ushort *chk_short, uint *chk_long, int max
// get the chksum of a pack file (VP)
int cf_chksum_pack(const char *filename, uint *chk_long, bool full)
{
const int safe_size = 2097152; // 2 Meg
const size_t safe_size = 2097152; // 2 Meg
const int header_offset = 32; // skip 32bytes for header (header is currently smaller than this though)
ubyte cf_buffer[CF_CHKSUM_SAMPLE_SIZE];
int cf_len = 0;
int cf_total;
int read_size;
int max_size;
size_t read_size;
size_t max_size;
if (chk_long == NULL) {
Int3();
@@ -1766,7 +1766,7 @@ int cf_chksum_pack(const char *filename, uint *chk_long, bool full)
// get the max size
fseek(fp, 0, SEEK_END);
max_size = ftell(fp);
max_size = (size_t)ftell(fp);
// maybe do a chksum of the entire file
if (full) {
@@ -1774,17 +1774,19 @@ int cf_chksum_pack(const char *filename, uint *chk_long, bool full)
}
// othewise it's only a partial check
else {
CLAMP(max_size, 0, safe_size);
if (max_size > safe_size) {
max_size = safe_size;
}
Assertion(max_size > header_offset,
"max_size (%d) > header_offset in packfile %s", max_size, filename);
"max_size (" SIZE_T_ARG ") > header_offset in packfile %s", max_size, filename);
max_size -= header_offset;
fseek(fp, -(max_size), SEEK_END);
fseek(fp, -((long)max_size), SEEK_END);
}
cf_total = 0;
size_t cf_total = 0;
size_t cf_len = 0;
do {
// determine how much we want to read
if ( (max_size - cf_total) >= CF_CHKSUM_SAMPLE_SIZE )
+4 -4
View File
@@ -138,7 +138,7 @@ CFILE *_cfopen(const char* source_file, int line, const char *filename, const ch
// like cfopen(), but it accepts a fully qualified path only (ie, the result of a cf_find_file_location() call)
// NOTE: only supports reading files!!
CFILE *_cfopen_special(const char* source_file, int line, const char *file_path, const char *mode,
const int size, const int offset, int dir_type = CF_TYPE_ANY);
const size_t size, const size_t offset, int dir_type = CF_TYPE_ANY);
#define cfopen_special(...) _cfopen_special(LOCATION, __VA_ARGS__) // Pass source location to the function
// Flush the open file buffer
@@ -238,7 +238,7 @@ int cf_chksum_pack(const char *filename, uint *chk_long, bool full = false);
ushort cf_add_chksum_short(ushort seed, ubyte *buffer, int size);
// update cur_chksum with the chksum of the new_data of size new_data_size
uint cf_add_chksum_long(uint seed, ubyte *buffer, int size);
uint cf_add_chksum_long(uint seed, ubyte *buffer, size_t size);
// convenient for misc checksumming purposes ------------------------------------------
@@ -324,7 +324,7 @@ void cf_sort_filenames( SCP_vector<SCP_string> &list, int sort, SCP_vector<file_
// size - File size
// offset - Offset into pack file. 0 if not a packfile.
// Returns: If not found returns 0.
int cf_find_file_location( const char *filespec, int pathtype, int max_out, char *pack_filename, int *size, int *offset, bool localize = false);
int cf_find_file_location( const char *filespec, int pathtype, int max_out, char *pack_filename, size_t *size, size_t *offset, bool localize = false);
// Searches for a file. Follows all rules and precedence and searches
// CD's and pack files. Searches all locations in order for first filename using ext filter list.
@@ -338,7 +338,7 @@ int cf_find_file_location( const char *filespec, int pathtype, int max_out, char
// offset - Offset into pack file. 0 if not a packfile.
// Returns: If not found returns -1, else returns offset into ext_list.
// (NOTE: This function is exponentially slow, so don't use it unless truely needed!!)
int cf_find_file_location_ext(const char *filename, const int ext_num, const char **ext_list, int pathtype, int max_out = 0, char *pack_filename = NULL, int *size = NULL, int *offset = NULL, bool localize = false);
int cf_find_file_location_ext(const char *filename, const int ext_num, const char **ext_list, int pathtype, int max_out = 0, char *pack_filename = NULL, size_t *size = NULL, size_t *offset = NULL, bool localize = false);
// Functions to change directories
int cfile_chdir(const char *dir);
+25 -27
View File
@@ -27,13 +27,14 @@
#include "luaconf.h"
#include <sstream>
#include <limits>
#define CHECK_POSITION
// Called once to setup the low-level reading code.
void cf_init_lowlevel_read_code( CFILE * cfile, int lib_offset, int size, int pos )
void cf_init_lowlevel_read_code( CFILE * cfile, size_t lib_offset, size_t size, size_t pos )
{
Assert(cfile != NULL);
@@ -47,13 +48,12 @@ void cf_init_lowlevel_read_code( CFILE * cfile, int lib_offset, int size, int po
if ( cb->fp ) {
if ( cb->lib_offset ) {
fseek( cb->fp, cb->lib_offset, SEEK_SET );
fseek( cb->fp, (long)cb->lib_offset, SEEK_SET );
}
#if defined(CHECK_POSITION) && !defined(NDEBUG)
int raw_position;
raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
auto raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
#endif
}
}
@@ -84,9 +84,8 @@ int cfeof(CFILE *cfile)
Assert(cb->fp != NULL);
#if defined(CHECK_POSITION) && !defined(NDEBUG)
int raw_position;
raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
auto raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
#endif
if (cb->raw_position >= cb->size ) {
@@ -116,12 +115,14 @@ int cftell( CFILE * cfile )
Assert(cb->fp != NULL);
#if defined(CHECK_POSITION) && !defined(NDEBUG)
int raw_position;
raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
auto raw_position = ftell(cb->fp) - cb->lib_offset;
Assert(raw_position == cb->raw_position);
#endif
return cb->raw_position;
// The rest of the code still uses ints, do an overflow check to detect cases where this fails
Assertion(cb->raw_position <= static_cast<size_t>(std::numeric_limits<int>::max()),
"Integer overflow in cftell, a file is probably too large (but I don't know which one).");
return (int) cb->raw_position;
}
@@ -143,7 +144,7 @@ int cfseek( CFILE *cfile, int offset, int where )
Assert( !cb->data );
Assert( cb->fp != NULL );
int goal_position;
size_t goal_position;
switch( where ) {
case CF_SEEK_SET:
@@ -162,13 +163,12 @@ int cfseek( CFILE *cfile, int offset, int where )
return 1;
}
int result = fseek(cb->fp, goal_position, SEEK_SET );
int result = fseek(cb->fp, (long)goal_position, SEEK_SET );
cb->raw_position = goal_position - cb->lib_offset;
#if defined(CHECK_POSITION) && !defined(NDEBUG)
int tmp_offset;
tmp_offset = (int)ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
auto tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
#endif
return result;
@@ -185,7 +185,7 @@ int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
if(!cf_is_valid(cfile))
return 0;
int size = elsize*nelem;
size_t size = elsize*nelem;
if(buf == NULL || size <= 0)
return 0;
@@ -208,7 +208,7 @@ int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
}
if (cb->max_read_len) {
if ( (size_t)(cb->raw_position+size) > cb->max_read_len ) {
if ( cb->raw_position+size > cb->max_read_len ) {
std::ostringstream s_buf;
s_buf << "Attempted to read " << size << "-byte(s) beyond length limit";
@@ -216,18 +216,17 @@ int cfread(void *buf, int elsize, int nelem, CFILE *cfile)
}
}
int bytes_read = fread( buf, 1, size, cb->fp );
size_t bytes_read = fread( buf, 1, size, cb->fp );
if ( bytes_read > 0 ) {
cb->raw_position += bytes_read;
}
#if defined(CHECK_POSITION) && !defined(NDEBUG)
int tmp_offset;
tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
auto tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
#endif
return bytes_read / elsize;
return (int)(bytes_read / elsize);
}
@@ -253,9 +252,8 @@ int cfread_lua_number(double *buf, CFILE *cfile)
cb->raw_position += ftell(cb->fp)-orig_pos;
#if defined(CHECK_POSITION) && !defined(NDEBUG)
int tmp_offset;
tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
auto tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
#endif
return items_read;
+4 -4
View File
@@ -34,9 +34,9 @@ typedef struct Cfile_block {
// int fd; // file descriptor
size_t data_length; // length of data for mmap
#endif
int lib_offset;
int raw_position;
int size; // for packed files
size_t lib_offset;
size_t raw_position;
size_t size; // for packed files
size_t max_read_len; // max read offset, for special error handling
@@ -48,6 +48,6 @@ typedef struct Cfile_block {
extern Cfile_block Cfile_block_list[MAX_CFILE_BLOCKS];
// Called once to setup the low-level reading code.
void cf_init_lowlevel_read_code( CFILE * cfile, int lib_offset, int size, int pos );
void cf_init_lowlevel_read_code( CFILE * cfile, size_t lib_offset, size_t size, size_t pos );
#endif
+1 -1
View File
@@ -420,7 +420,7 @@ int cfread_compressed(void *buf, int elsize, int nelem, CFILE *cfile)
}
}
return (out - (char *)buf)/elsize;
return (int)((out - (char *)buf)/elsize);
}
int cfwrite_compressed(void *param_buf, int param_elsize, int param_nelem, CFILE *cfile)
+40 -33
View File
@@ -178,7 +178,7 @@ int cf_get_packfile_count(cf_root *root)
#if defined _WIN32
filespec += "*.vp";
int find_handle;
intptr_t find_handle;
_finddata_t find;
find_handle = _findfirst( filespec.c_str( ), &find );
@@ -266,7 +266,7 @@ void cf_build_pack_list( cf_root *root )
#if defined _WIN32
strcat_s( filespec, "*.vp" );
int find_handle;
intptr_t find_handle;
_finddata_t find;
find_handle = _findfirst( filespec, &find );
@@ -359,6 +359,16 @@ void cf_build_pack_list( cf_root *root )
vm_free(temp_roots_sort);
}
static char normalize_directory_separator(char in)
{
if (in == '/')
{
return DIR_SEPARATOR_CHAR;
}
return in;
}
static void cf_add_mod_roots(const char* rootDirectory)
{
if (Cmdline_mod)
@@ -380,6 +390,9 @@ static void cf_add_mod_roots(const char* rootDirectory)
Error(LOCATION, "The length of mod directory path '%s' exceeds the maximum of %d!\n", rootPath.c_str(), CF_MAX_PATHNAME_LENGTH);
}
// normalize the path to the native path format
std::transform(rootPath.begin(), rootPath.end(), rootPath.begin(), normalize_directory_separator);
cf_root* root = cf_create_root();
strncpy(root->path, rootPath.c_str(), CF_MAX_PATHNAME_LENGTH-1);
@@ -396,7 +409,6 @@ void cf_build_root_list(const char *cdrom_dir)
Num_path_roots = 0;
cf_root *root = nullptr;
int path_len;
if (os_is_legacy_mode())
{
@@ -463,7 +475,7 @@ void cf_build_root_list(const char *cdrom_dir)
strcpy_s(root->path, working_directory);
path_len = strlen(root->path);
size_t path_len = strlen(root->path);
// do we already have a slash? as in the case of a root directory install
if ( (path_len < (CF_MAX_PATHNAME_LENGTH-1)) && (root->path[path_len-1] != DIR_SEPARATOR_CHAR) ) {
@@ -542,7 +554,7 @@ void cf_search_root_path(int root_index)
#if defined _WIN32
strcat_s( search_path, "*.*" );
int find_handle;
intptr_t find_handle;
_finddata_t find;
find_handle = _findfirst( search_path, &find );
@@ -701,7 +713,7 @@ void cf_search_root_pack(int root_index)
find.filename[sizeof(find.filename)-1] = '\0';
if ( find.size == 0 ) {
int search_path_len = strlen(search_path);
size_t search_path_len = strlen(search_path);
if ( !stricmp( find.filename, ".." )) {
char *p = &search_path[search_path_len-1];
while( (p > search_path) && (*p != DIR_SEPARATOR_CHAR) ) {
@@ -837,18 +849,13 @@ void cf_free_secondary_filelist()
*
* @return If not found returns 0.
*/
int cf_find_file_location( const char *filespec, int pathtype, int max_out, char *pack_filename, int *size, int *offset, bool localize )
int cf_find_file_location( const char *filespec, int pathtype, int max_out, char *pack_filename, size_t *size, size_t *offset, bool localize )
{
int i;
uint ui;
int cfs_slow_search = 0;
char longname[MAX_PATH_LEN];
#if defined WIN32
long findhandle;
_finddata_t findstruct;
#endif
Assert( (filespec != NULL) && (strlen(filespec) > 0) ); //-V805
Assert( (pack_filename == NULL) || (max_out > 1) );
@@ -917,7 +924,9 @@ int cf_find_file_location( const char *filespec, int pathtype, int max_out, char
cf_create_default_path_string( longname, sizeof(longname)-1, search_order[ui], filespec, localize );
#if defined _WIN32
findhandle = _findfirst(longname, &findstruct);
_finddata_t findstruct;
intptr_t findhandle = _findfirst(longname, &findstruct);
if (findhandle != -1) {
if (size)
*size = findstruct.size;
@@ -973,7 +982,7 @@ int cf_find_file_location( const char *filespec, int pathtype, int max_out, char
*size = f->size;
if (offset)
*offset = f->pack_offset;
*offset = (size_t)f->pack_offset;
if (pack_filename) {
cf_root *r = cf_get_root(f->root_index);
@@ -1001,7 +1010,7 @@ int cf_find_file_location( const char *filespec, int pathtype, int max_out, char
*size = f->size;
if (offset)
*offset = f->pack_offset;
*offset = (size_t)f->pack_offset;
if (pack_filename) {
cf_root *r = cf_get_root(f->root_index);
@@ -1048,7 +1057,7 @@ extern char *stristr(char *str, const char *substr);
*
* @return If not found returns -1, else returns offset into ext_list.
*/
int cf_find_file_location_ext( const char *filename, const int ext_num, const char **ext_list, int pathtype, int max_out, char *pack_filename, int *size, int *offset, bool localize )
int cf_find_file_location_ext( const char *filename, const int ext_num, const char **ext_list, int pathtype, int max_out, char *pack_filename, size_t *size, size_t *offset, bool localize )
{
int cur_ext, i;
uint ui;
@@ -1056,12 +1065,7 @@ int cf_find_file_location_ext( const char *filename, const int ext_num, const ch
char longname[MAX_PATH_LEN];
char filespec[MAX_FILENAME_LEN];
char *p = NULL;
#if defined WIN32
long findhandle;
_finddata_t findstruct;
#endif
Assert( (filename != NULL) && (strlen(filename) < MAX_FILENAME_LEN) );
Assert( (ext_list != NULL) && (ext_num > 1) ); // if we are searching for just one ext
// then this is the wrong function to use
@@ -1132,7 +1136,8 @@ int cf_find_file_location_ext( const char *filename, const int ext_num, const ch
cf_create_default_path_string( longname, sizeof(longname)-1, search_order[ui], filespec, localize );
#if defined _WIN32
findhandle = _findfirst(longname, &findstruct);
_finddata_t findstruct;
intptr_t findhandle = _findfirst(longname, &findstruct);
if (findhandle != -1) {
if (size)
*size = findstruct.size;
@@ -1179,11 +1184,11 @@ int cf_find_file_location_ext( const char *filename, const int ext_num, const ch
(*p) = 0;
// go ahead and get our length, which is used to test with later
int filespec_len = strlen(filespec);
size_t filespec_len = strlen(filespec);
// get total legnth, with extension, which is iused to test with later
// (FIXME: this assumes that everything in ext_list[] is the same length!)
uint filespec_len_big = filespec_len + strlen(ext_list[0]);
size_t filespec_len_big = filespec_len + strlen(ext_list[0]);
SCP_vector< cf_file* > file_list_index;
int last_root_index = -1;
@@ -1419,7 +1424,8 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *fi
{
char *ptr;
uint i;
int l, own_flag = 0;
int own_flag = 0;
size_t l;
SCP_vector<file_list_info> my_info;
file_list_info tinfo;
@@ -1447,7 +1453,7 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *fi
strcat_s(filespec, filter);
_finddata_t find;
int find_handle;
intptr_t find_handle;
find_handle = _findfirst( filespec, &find );
if (find_handle != -1) {
@@ -1463,7 +1469,7 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *fi
ptr = strrchr(find.name, '.');
if (ptr)
l = ptr - find.name;
l = (size_t)(ptr - find.name);
else
l = strlen(find.name);
@@ -1514,7 +1520,7 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *fi
ptr = strrchr(dir->d_name, '.');
if (ptr)
l = ptr - dir->d_name;
l = (size_t)(ptr - dir->d_name);
else
l = strlen(dir->d_name);
@@ -1562,7 +1568,7 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, const char *fi
ptr = strrchr(f->name_ext, '.');
if (ptr)
l = ptr - f->name_ext;
l = (size_t)(ptr - f->name_ext);
else
l = strlen(f->name_ext);
@@ -1620,7 +1626,8 @@ int cf_get_file_list( int max, char **list, int pathtype, const char *filter, in
{
char *ptr;
uint i;
int l, num_files = 0, own_flag = 0;
int num_files = 0, own_flag = 0;
size_t l;
if (max < 1) {
Get_file_list_filter = NULL;
@@ -1641,7 +1648,7 @@ int cf_get_file_list( int max, char **list, int pathtype, const char *filter, in
cf_create_default_path_string( filespec, sizeof(filespec)-1, pathtype, filter );
_finddata_t find;
int find_handle;
intptr_t find_handle;
find_handle = _findfirst( filespec, &find );
if (find_handle != -1) {
@@ -1846,7 +1853,7 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
#if defined _WIN32
cf_create_default_path_string( filespec, sizeof(filespec)-1, pathtype, filter );
int find_handle;
intptr_t find_handle;
_finddata_t find;
find_handle = _findfirst( filespec, &find );
+3
View File
@@ -8,6 +8,9 @@ set_target_properties(cfilearchiver
PROPERTIES
FOLDER "FSOTools"
)
TARGET_LINK_LIBRARIES(cfilearchiver PUBLIC ${SDL_LIBS})
TARGET_INCLUDE_DIRECTORIES(cfilearchiver PUBLIC ${GENERATED_SOURCE_DIR})
TARGET_INCLUDE_DIRECTORIES(cfilearchiver PUBLIC ${GENERATED_SOURCE_DIR}/code)
IF(MSVC)
set_target_properties(cfilearchiver PROPERTIES
+3
View File
@@ -8,6 +8,9 @@ set_target_properties(cfileextractor
PROPERTIES
FOLDER "FSOTools"
)
TARGET_LINK_LIBRARIES(cfileextractor PUBLIC ${SDL_LIBS})
TARGET_INCLUDE_DIRECTORIES(cfileextractor PUBLIC ${GENERATED_SOURCE_DIR})
TARGET_INCLUDE_DIRECTORIES(cfileextractor PUBLIC ${GENERATED_SOURCE_DIR}/code)
IF(MSVC)
set_target_properties(cfileextractor PROPERTIES
+48 -28
View File
@@ -157,6 +157,7 @@ Flag exe_params[] =
{ "-fxaa", "Enable FXAA anti-aliasing", true, EASY_MEM_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fxaa" },
{ "-nolightshafts", "Disable lightshafts", true, EASY_DEFAULT, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-flightshaftsoff"},
{ "-fb_explosions", "Enable Framebuffer Shockwaves", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fb_explosions", },
{ "-fb_thrusters", "Enable Framebuffer Thrusters", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fb_thrusters", },
{ "-no_deferred", "Disable Deferred Lighting", true, EASY_DEFAULT_MEM, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_deferred"},
{ "-enable_shadows", "Enable Shadows", true, EASY_MEM_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_shadows"},
{ "-no_vsync", "Disable vertical sync", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_vsync", },
@@ -180,6 +181,8 @@ Flag exe_params[] =
{ "-nomusic", "Disable music", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomusic", },
{ "-no_enhanced_sound", "Disable enhanced sound", false, 0, EASY_DEFAULT, "Audio", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_enhanced_sound", },
{ "-portable_mode", "Store config in portable location", false, 0, EASY_DEFAULT, "Launcher", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-portable_mode", },
{ "-standalone", "Run as standalone server", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-standalone", },
{ "-startgame", "Skip mainhall and start hosting", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-startgame", },
{ "-closed", "Start hosted server as closed", false, 0, EASY_DEFAULT, "Multiplayer", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-closed", },
@@ -235,6 +238,7 @@ Flag exe_params[] =
{ "-profile_write_file", "Write profiling information to file", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-profile_write_file", },
{ "-no_unfocused_pause","Don't pause if the window isn't focused", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_unfocused_pause", },
{ "-benchmark_mode", "Puts the game into benchmark mode", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-benchmark_mode", },
{ "-noninteractive", "Disables interactive dialogs", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noninteractive", },
};
// forward declaration
@@ -312,6 +316,7 @@ cmdline_parm bloom_intensity_arg("-bloom_intensity", "Set bloom intensity, requi
cmdline_parm fxaa_arg("-fxaa", NULL, AT_NONE);
cmdline_parm fxaa_preset_arg("-fxaa_preset", "FXAA quality (0-9), requires -post_process and -fxaa", AT_INT);
cmdline_parm fb_explosions_arg("-fb_explosions", NULL, AT_NONE);
cmdline_parm fb_thrusters_arg("-fb_thrusters", NULL, AT_NONE);
cmdline_parm flightshaftsoff_arg("-nolightshafts", NULL, AT_NONE);
cmdline_parm no_batching("-no_batching", NULL, AT_NONE);
cmdline_parm shadow_quality_arg("-shadow_quality", NULL, AT_INT);
@@ -340,6 +345,7 @@ bool Cmdline_fxaa = false;
int Cmdline_fxaa_preset = 6;
extern int Fxaa_preset_last_frame;
bool Cmdline_fb_explosions = 0;
bool Cmdline_fb_thrusters = false;
bool Cmdline_no_batching = false;
extern bool ls_force_off;
int Cmdline_shadow_quality = 0;
@@ -461,9 +467,6 @@ cmdline_parm start_mission_arg("-start_mission", "Skip mainhall and run this mis
cmdline_parm dis_collisions("-dis_collisions", NULL, AT_NONE); // Cmdline_dis_collisions
cmdline_parm dis_weapons("-dis_weapons", NULL, AT_NONE); // Cmdline_dis_weapons
cmdline_parm noparseerrors_arg("-noparseerrors", NULL, AT_NONE); // Cmdline_noparseerrors -- turns off parsing errors -C
#ifdef Allow_NoWarn
cmdline_parm nowarn_arg("-no_warn", "Disable warnings (not recommended)", AT_NONE); // Cmdline_nowarn
#endif
cmdline_parm extra_warn_arg("-extra_warn", "Enable 'extra' warnings", AT_NONE); // Cmdline_extra_warn
cmdline_parm fps_arg("-fps", NULL, AT_NONE); // Cmdline_show_fps
cmdline_parm show_mem_usage_arg("-show_mem_usage", NULL, AT_NONE); // Cmdline_show_mem_usage
@@ -481,6 +484,7 @@ cmdline_parm frame_profile_arg("-profile_frame_time", NULL, AT_NONE); //Cmdline_
cmdline_parm frame_profile_write_file("-profile_write_file", NULL, AT_NONE); // Cmdline_profile_write_file
cmdline_parm no_unfocused_pause_arg("-no_unfocused_pause", NULL, AT_NONE); //Cmdline_no_unfocus_pause
cmdline_parm benchmark_mode_arg("-benchmark_mode", NULL, AT_NONE); //Cmdline_benchmark_mode
cmdline_parm noninteractive_arg("-noninteractive", NULL, AT_NONE); //Cmdline_noninteractive
char *Cmdline_start_mission = NULL;
@@ -506,6 +510,7 @@ bool Cmdline_frame_profile = false;
bool Cmdline_profile_write_file = false;
bool Cmdline_no_unfocus_pause = false;
bool Cmdline_benchmark_mode = false;
bool Cmdline_noninteractive = false;
// Other
cmdline_parm get_flags_arg("-get_flags", "Output the launcher flags file", AT_NONE);
@@ -608,17 +613,20 @@ int is_extra_space(char ch)
// eliminates all leading and trailing extra chars from a string. Returns pointer passed in.
char *drop_extra_chars(char *str)
{
int s, e;
size_t s;
size_t e;
s = 0;
while (str[s] && is_extra_space(str[s]))
s++;
e = strlen(str) - 1; // we already account for NULL later on, so the -1 is here to make
// sure we do our math without taking it into consideration
e = strlen(str);
if (e < 0)
e = 0;
if (e > 0) {
// we already account for NULL later on, so the -1 is here to make
// sure we do our math without taking it into consideration
e -= 1;
}
while (e > s) {
if (!is_extra_space(str[e])){
@@ -673,8 +681,8 @@ bool parm_stuff_args(cmdline_parm *parm, int argc, char *argv[], int index)
parm->args = NULL;
}
int argsize = strlen(argv[index + 1]);
int buffersize = argsize;
size_t argsize = strlen(argv[index + 1]);
size_t buffersize = argsize;
if (saved_args != NULL)
{
@@ -785,16 +793,17 @@ void os_validate_parms(int argc, char *argv[])
// not the prettiest thing but the job gets done
static const int STR_SIZE = 25; // max len of exe_params.name + 5 spaces
const int AT_SIZE = 8; // max len of cmdline_arg_types[] + 2 spaces
int sp=0, atp=0;
size_t atp = 0;
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)) {
sp = strlen(parmp->name);
if (parmp->arg_type != AT_NONE) {
atp = strlen(cmdline_arg_types[parmp->arg_type]);
printf(" [ %s ]%*s[ %s ]%*s- %s\n", parmp->name, (STR_SIZE - sp -1), NOX(" "), cmdline_arg_types[parmp->arg_type], AT_SIZE-atp, NOX(" "), parmp->help);
printf(" [ %s ]%*s[ %s ]%*s- %s\n", parmp->name, (int)(STR_SIZE - sp -1), NOX(" "), cmdline_arg_types[parmp->arg_type], (int)(AT_SIZE-atp), NOX(" "), parmp->help);
} else {
printf(" [ %s ]%*s- %s\n", parmp->name, (STR_SIZE - sp -1 +AT_SIZE+4), NOX(" "), parmp->help);
printf(" [ %s ]%*s- %s\n", parmp->name, (int)(STR_SIZE - sp -1 +AT_SIZE+4), NOX(" "), parmp->help);
}
}
}
@@ -815,14 +824,14 @@ void os_validate_parms(int argc, char *argv[])
int parse_cmdline_string(char* cmdline, char** argv)
{
int length = strlen(cmdline);
size_t length = strlen(cmdline);
bool start_found = false;
bool quoted = false;
int argc = 0;
size_t argc = 0;
char* current_argv = NULL;
for (int i = 0; i < length; i++)
for (size_t i = 0; i < length; i++)
{
if (!start_found && !isspace(cmdline[i]))
{
@@ -883,7 +892,7 @@ int parse_cmdline_string(char* cmdline, char** argv)
argc++;
}
return argc;
return (int)argc;
}
void os_process_cmdline(char* cmdline)
@@ -943,7 +952,7 @@ void os_init_cmdline(int argc, char *argv[])
if (fp) {
char *buf, *p;
size_t len = filelength(fileno(fp)) + 2;
auto len = static_cast<int>(filelength(fileno(fp))) + 2;
buf = new char[len];
if (fgets(buf, len - 1, fp) != nullptr)
@@ -971,7 +980,7 @@ void os_init_cmdline(int argc, char *argv[])
if ( fp ) {
char *buf, *p;
size_t len = filelength( fileno(fp) ) + 2;
auto len = static_cast<int>(filelength( fileno(fp) )) + 2;
buf = new char [len];
if (fgets(buf, len-1, fp) != nullptr)
@@ -1066,7 +1075,7 @@ int cmdline_parm::get_int()
Assertion(arg_type == AT_INT, "Coding error! Cmdline arg (%s) called cmdline_parm::get_int() with invalid arg_type (%s)", name, cmdline_arg_types[arg_type]);
check_if_args_is_valid();
int offset = 0;
size_t offset = 0;
if (stacks) {
// first off, DON'T STACK NON-STRINGS!!
@@ -1091,7 +1100,7 @@ float cmdline_parm::get_float()
Assertion(arg_type == AT_FLOAT, "Coding error! Cmdline arg (%s) called cmdline_parm::get_float() with invalid arg_type (%s)", name, cmdline_arg_types[arg_type]);
check_if_args_is_valid();
int offset = 0;
size_t offset = 0;
if (stacks) {
// first off, DON'T STACK NON-STRINGS!!
@@ -1178,7 +1187,7 @@ static SCP_vector<SCP_string> unix_get_dir_names(SCP_string parent, SCP_string d
}
// For case sensitive filesystems (e.g. Linux/BSD) perform case-insensitive dir matches.
static void handle_unix_modlist(char **modlist, int *len)
static void handle_unix_modlist(char **modlist, size_t *len)
{
// search filesystem for given paths
SCP_vector<SCP_string> mod_paths;
@@ -1488,7 +1497,7 @@ bool SetCmdlineParams()
}
// Ok - mod stacking support
int len = strlen(Cmdline_mod);
size_t len = strlen(Cmdline_mod);
char *modlist = new char[len+2];
memset( modlist, 0, len + 2 );
strcpy_s(modlist, len+2, Cmdline_mod);
@@ -1499,7 +1508,7 @@ bool SetCmdlineParams()
#endif
// null terminate each individual
for (int i = 0; i < len; i++)
for (size_t i = 0; i < len; i++)
{
if (modlist[i] == ',')
modlist[i] = '\0';
@@ -1772,6 +1781,11 @@ bool SetCmdlineParams()
Cmdline_fb_explosions = 1;
}
if (fb_thrusters_arg.found())
{
Cmdline_fb_thrusters = true;
}
if ( no_batching.found() )
{
Cmdline_no_batching = true;
@@ -1800,10 +1814,11 @@ bool SetCmdlineParams()
if( enable_shadows_arg.found() )
{
Cmdline_shadow_quality = 2;
if( shadow_quality_arg.found() )
{
Cmdline_shadow_quality = shadow_quality_arg.get_int();
}
}
if( shadow_quality_arg.found() )
{
Cmdline_shadow_quality = shadow_quality_arg.get_int();
}
if( no_deferred_lighting_arg.found() )
@@ -1832,6 +1847,11 @@ bool SetCmdlineParams()
Cmdline_benchmark_mode = true;
}
if (noninteractive_arg.found())
{
Cmdline_noninteractive = true;
}
//Deprecated flags - CommanderDJ
if( deprecated_spec_arg.found() )
{
+2 -3
View File
@@ -76,6 +76,7 @@ extern int Cmdline_bloom_intensity;
extern bool Cmdline_fxaa;
extern int Cmdline_fxaa_preset;
extern bool Cmdline_fb_explosions;
extern bool Cmdline_fb_thrusters;
extern bool Cmdline_no_batching;
extern int Cmdline_shadow_quality;
extern int Cmdline_no_deferred_lighting;
@@ -145,9 +146,6 @@ extern int Cmdline_old_collision_sys;
extern int Cmdline_dis_collisions;
extern int Cmdline_dis_weapons;
extern int Cmdline_noparseerrors;
#ifdef Allow_NoWarn
extern int Cmdline_nowarn;
#endif
extern int Cmdline_extra_warn;
extern int Cmdline_show_mem_usage;
extern int Cmdline_show_pos;
@@ -159,5 +157,6 @@ extern bool Cmdline_frame_profile;
extern bool Cmdline_profile_write_file;
extern bool Cmdline_no_unfocus_pause;
extern bool Cmdline_benchmark_mode;
extern bool Cmdline_noninteractive;
#endif
+1 -1
View File
@@ -93,7 +93,7 @@ void cmeasure_maybe_alert_success(object *objp)
if ( objp->parent == OBJ_INDEX(Player_obj) ) {
hud_start_text_flash(XSTR("Evaded", 1430), 800);
snd_play(&Snds[ship_get_sound(Player_obj, SND_MISSILE_EVADED_POPUP)]);
} else if ( Objects[objp->parent].flags & OF_PLAYER_SHIP ) {
} else if ( Objects[objp->parent].flags[Object::Object_Flags::Player_ship] ) {
send_countermeasure_success_packet( objp->parent );
}
}
+74 -16
View File
@@ -356,6 +356,65 @@ 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)
{
int rng;
rng = JOY_AXIS_MAX - JOY_AXIS_MIN;
raw -= JOY_AXIS_MIN; // adjust for linear range starting at 0
// cap at limits
if (raw < 0)
raw = 0;
if (raw > rng)
raw = rng;
return (int) ((uint) raw * (uint) F1_0 / (uint) rng); // convert to 0 - F1_0 range.
}
int joy_get_scaled_reading(int raw)
{
int x, d, dead_zone, rng;
float percent, sensitivity_percent, non_sensitivity_percent;
raw -= JOY_AXIS_CENTER;
dead_zone = (JOY_AXIS_MAX - JOY_AXIS_MIN) * Joy_dead_zone_size / 100;
if (raw < -dead_zone) {
rng = JOY_AXIS_CENTER - JOY_AXIS_MIN - dead_zone;
d = -raw - dead_zone;
} else if (raw > dead_zone) {
rng = JOY_AXIS_MAX - JOY_AXIS_CENTER - dead_zone;
d = raw - dead_zone;
} else
return 0;
if (d > rng)
d = rng;
Assert(Joy_sensitivity >= 0 && Joy_sensitivity <= 9);
// compute percentages as a range between 0 and 1
sensitivity_percent = (float) Joy_sensitivity / 9.0f;
non_sensitivity_percent = (float) (9 - Joy_sensitivity) / 9.0f;
// find percent of max axis is at
percent = (float) d / (float) rng;
// work sensitivity on axis value
percent = (percent * sensitivity_percent + percent * percent * percent * percent * percent * non_sensitivity_percent);
x = (int) ((float) F1_0 * percent);
//nprintf(("AI", "d=%6i, sens=%3i, percent=%6.3f, val=%6i, ratio=%6.3f\n", d, Joy_sensitivity, percent, (raw<0) ? -x : x, (float) d/x));
if (raw < 0)
return -x;
return x;
}
void control_config_detect_axis_reset()
{
joystick_read_raw_axis(JOY_NUM_AXES, Axes_origin);
@@ -833,8 +892,6 @@ int control_config_clear_all()
return 0;
}
extern Joy_info joystick;
int control_config_axis_default(int axis)
{
Assert(axis >= 0);
@@ -844,7 +901,8 @@ int control_config_axis_default(int axis)
return -1;
}
if (!joystick.axis_valid[Axis_map_to_defaults[axis]]) {
auto joystick = io::joystick::getCurrentJoystick();
if (joystick == nullptr || Axis_map_to_defaults[axis] >= joystick->numAxes()) {
return -1;
}
}
@@ -1470,7 +1528,7 @@ void control_config_do_frame(float frametime)
if (Axis_override >= 0) {
control_config_bind_axis(z, Axis_override);
strcpy_s(bound_string, Joy_axis_text[Axis_override]);
gr_force_fit_string(bound_string, 39, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
font::force_fit_string(bound_string, 39, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
bound_timestamp = timestamp(2500);
control_config_conflict_check();
control_config_list_prepare();
@@ -1538,7 +1596,7 @@ void control_config_do_frame(float frametime)
control_config_bind_key(z, k);
strcpy_s(bound_string, textify_scancode(k));
gr_force_fit_string(bound_string, 39, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
font::force_fit_string(bound_string, 39, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
bound_timestamp = timestamp(2500);
control_config_conflict_check();
control_config_list_prepare();
@@ -1552,7 +1610,7 @@ void control_config_do_frame(float frametime)
control_config_bind_joy(z, i);
strcpy_s(bound_string, Joy_button_text[i]);
gr_force_fit_string(bound_string, 39, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
font::force_fit_string(bound_string, 39, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
bound_timestamp = timestamp(2500);
control_config_conflict_check();
control_config_list_prepare();
@@ -1576,7 +1634,7 @@ void control_config_do_frame(float frametime)
control_config_bind_joy(z, i);
strcpy_s(bound_string, Joy_button_text[i]);
gr_force_fit_string(bound_string, 39, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
font::force_fit_string(bound_string, 39, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
bound_timestamp = timestamp(2500);
control_config_conflict_check();
control_config_list_prepare();
@@ -1847,7 +1905,7 @@ void control_config_do_frame(float frametime)
}
// set color and font
gr_set_font(FONT2);
font::set_font(font::FONT2);
if(Conflict_bright){
gr_set_color_fast(&Color_bright_red);
} else {
@@ -1862,7 +1920,7 @@ void control_config_do_frame(float frametime)
gr_string((gr_screen.max_w / 2) - (sw / 2), Conflict_warning_coords[gr_screen.res][1], conflict_str, GR_RESIZE_MENU);
gr_set_font(FONT1);
font::set_font(font::FONT1);
} else {
// might as well always reset the conflict stamp
Conflict_stamp = -1;
@@ -1936,7 +1994,7 @@ void control_config_do_frame(float frametime)
strcpy_s(buf, Control_config[i].text);
}
gr_force_fit_string(buf, 255, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
font::force_fit_string(buf, 255, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
gr_get_string_size(&w, NULL, buf);
gr_printf_menu(x - w / 2, y, buf);
@@ -1976,7 +2034,7 @@ void control_config_do_frame(float frametime)
gr_set_color_fast(c);
if (Cc_lines[line].label) {
strcpy_s(buf, Cc_lines[line].label);
gr_force_fit_string(buf, 255, Control_list_ctrl_w[gr_screen.res]);
font::force_fit_string(buf, 255, Control_list_ctrl_w[gr_screen.res]);
gr_printf_menu(Control_list_coords[gr_screen.res][CONTROL_X_COORD], y, buf);
}
@@ -2040,7 +2098,7 @@ void control_config_do_frame(float frametime)
gr_set_color_fast(c);
}
gr_force_fit_string(buf, 255, Control_list_key_w[gr_screen.res] + Control_list_key_x[gr_screen.res] - x);
font::force_fit_string(buf, 255, Control_list_key_w[gr_screen.res] + Control_list_key_x[gr_screen.res] - x);
gr_printf_menu(x, y, buf);
Cc_lines[line].jx = x - Control_list_coords[gr_screen.res][CONTROL_X_COORD];
@@ -2306,17 +2364,17 @@ void control_get_axes_readings(int *h, int *p, int *b, int *ta, int *tr)
// joy_get_scaled_reading will return a value represents the joystick pos from -1 to +1 (fixed point)
*h = 0;
if (Axis_map_to[0] >= 0) {
*h = joy_get_scaled_reading(axes_values[Axis_map_to[0]], Axis_map_to[0]);
*h = joy_get_scaled_reading(axes_values[Axis_map_to[0]]);
}
*p = 0;
if (Axis_map_to[1] >= 0) {
*p = joy_get_scaled_reading(axes_values[Axis_map_to[1]], Axis_map_to[1]);
*p = joy_get_scaled_reading(axes_values[Axis_map_to[1]]);
}
*b = 0;
if (Axis_map_to[2] >= 0) {
*b = joy_get_scaled_reading(axes_values[Axis_map_to[2]], Axis_map_to[2]);
*b = joy_get_scaled_reading(axes_values[Axis_map_to[2]]);
}
*ta = 0;
@@ -2326,7 +2384,7 @@ void control_get_axes_readings(int *h, int *p, int *b, int *ta, int *tr)
*tr = 0;
if (Axis_map_to[4] >= 0) {
*tr = joy_get_scaled_reading(axes_values[Axis_map_to[4]], Axis_map_to[4]);
*tr = joy_get_scaled_reading(axes_values[Axis_map_to[4]]);
}
if (Invert_axis[0]) {
+5
View File
@@ -288,6 +288,9 @@ extern int Axis_map_to[];
extern int Invert_axis[];
extern int Invert_axis_defaults[];
extern int Joy_dead_zone_size;
extern int Joy_sensitivity;
extern int Control_config_overlay_id;
extern config_item Control_config[]; //!< Stores the keyboard configuration
@@ -318,4 +321,6 @@ void clear_key_binding(short key);
void control_check_indicate();
void control_config_clear_used_status();
int joy_get_scaled_reading(int raw);
#endif
+4 -1
View File
@@ -18,7 +18,6 @@
#include "io/key.h"
#include "localization/localize.h"
#include "parse/parselo.h"
#include "def_files/def_files.h"
// z64: These enumerations MUST equal to those in controlsconfig.cpp...
// z64: Really need a better way than this.
@@ -31,6 +30,10 @@ enum CC_tab {
int Failed_key_index;
// Joystick configuration
int Joy_dead_zone_size = 10;
int Joy_sensitivity = 9;
// assume control keys are used as modifiers until we find out
int Shift_is_modifier;
int Ctrl_is_modifier;
+1 -1
View File
@@ -44,7 +44,7 @@ int movie_find(char *filename, char *out_name)
{
char full_path[MAX_PATH];
char tmp_name[MAX_PATH];
int size, offset = 0;
size_t size, offset = 0;
if (out_name == NULL)
return MOVIE_NONE;
+6 -14
View File
@@ -13,7 +13,6 @@
#include "graphics/2d.h"
#include "graphics/gropengl.h"
#include "graphics/gropengldraw.h"
#include "graphics/gropenglextension.h"
#include "graphics/gropenglstate.h"
#include "graphics/gropenglshader.h"
#include "graphics/gropengltexture.h"
@@ -70,8 +69,6 @@ ushort *pixelbuf = NULL;
static GLuint GLtex = 0;
static GLfloat gl_screenYH = 0;
static GLfloat gl_screenXW = 0;
static GLfloat gl_screenU = 0;
static GLfloat gl_screenV = 0;
static GLfloat glVertices[4][4] = {{0}};
static int g_screenWidth, g_screenHeight;
static float g_screenX, g_screenY;
@@ -80,12 +77,10 @@ static ubyte g_palette[768];
static ubyte *g_pCurMap = NULL;
static int g_nMapLength = 0;
static int videobuf_created, video_inited;
static int hp2, wp2;
static uint mve_video_skiptimer = 0;
static int mve_scale_video = 0;
// video externs from API graphics functions
extern void opengl_tcache_get_adjusted_texture_size(int w_in, int h_in, int *w_out, int *h_out);
extern GLenum GL_previous_texture_target;
// the decoders
@@ -486,9 +481,6 @@ int mve_video_createbuf(ubyte minor, ubyte *data)
if (gr_screen.mode == GR_OPENGL) {
gl_screenYH = g_screenY + g_height;
gl_screenXW = g_screenX + g_width;
gl_screenU = i2fl(g_width) / i2fl(wp2);
gl_screenV = i2fl(g_height) / i2fl(hp2);
}
glVertices[0][0] = g_screenX;
@@ -499,17 +491,17 @@ int mve_video_createbuf(ubyte minor, ubyte *data)
glVertices[1][0] = g_screenX;
glVertices[1][1] = gl_screenYH;
glVertices[1][2] = 0;
glVertices[1][3] = gl_screenV;
glVertices[1][3] = 1.f;
glVertices[2][0] = gl_screenXW;
glVertices[2][1] = g_screenY;
glVertices[2][2] = gl_screenU;
glVertices[2][2] = 1.f;
glVertices[2][3] = 0;
glVertices[3][0] = gl_screenXW;
glVertices[3][1] = gl_screenYH;
glVertices[3][2] = gl_screenU;
glVertices[3][3] = gl_screenV;
glVertices[3][2] = 1.f;
glVertices[3][3] = 1.f;
GL_state.Array.BindArrayBuffer(0);
@@ -602,6 +594,7 @@ void mve_video_display()
}
if (gr_screen.mode == GR_OPENGL) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexSubImage2D(GL_state.Texture.GetTarget(), 0, 0, 0, g_width, g_height, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, pixelbuf);
opengl_shader_set_passthrough(true);
@@ -665,7 +658,6 @@ int mve_video_init(ubyte *data)
if (gr_screen.mode == GR_OPENGL) {
opengl_set_texture_target(GL_TEXTURE_2D);
opengl_tcache_get_adjusted_texture_size(g_screenWidth, g_screenHeight, &wp2, &hp2);
glGenTextures(1, &GLtex);
@@ -694,7 +686,7 @@ int mve_video_init(ubyte *data)
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// NOTE: using NULL instead of pixelbuf crashes some drivers, but then so does pixelbuf
glTexImage2D(GL_state.Texture.GetTarget(), 0, GL_RGB5_A1, wp2, hp2, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL);
glTexImage2D(GL_state.Texture.GetTarget(), 0, GL_RGB5_A1, g_screenWidth, g_screenHeight, 0, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL);
// set our color so that we can make sure that it's correct
GL_state.Color(255, 255, 255, 255);
+6 -12
View File
@@ -13,12 +13,10 @@
#include "cfile/cfile.h"
#include "cutscene/oggplayer.h"
#include "def_files/def_files.h"
#include "def_files/def_files.h"
#include "globalincs/pstypes.h"
#include "graphics/2d.h"
#include "graphics/gropengl.h"
#include "graphics/gropengldraw.h"
#include "graphics/gropenglextension.h"
#include "graphics/gropenglshader.h"
#include "graphics/gropenglstate.h"
#include "graphics/gropengltexture.h"
@@ -34,7 +32,6 @@
extern int Cmdline_noscalevid;
static int hp2, wp2;
static int video_inited = 0;
static int scale_video = 0;
static int playing = 1;
@@ -54,9 +51,6 @@ static GLfloat gl_screenU = 0;
static GLfloat gl_screenV = 0;
static GLfloat glVertices[4][4] = {{0}};
// video externs from API graphics functions
extern void opengl_tcache_get_adjusted_texture_size(int w_in, int h_in, int *w_out, int *h_out);
static int timer_started = 0;
static longlong base_time = -1;
#ifdef SCP_UNIX
@@ -344,7 +338,6 @@ static void OGG_video_init(theora_info *tinfo)
if (gr_screen.mode == GR_OPENGL) {
opengl_set_texture_target(GL_TEXTURE_2D);
opengl_tcache_get_adjusted_texture_size(g_screenWidth, g_screenHeight, &wp2, &hp2);
if(!is_minimum_GLSL_version())
use_shaders = false;
@@ -396,7 +389,7 @@ static void OGG_video_init(theora_info *tinfo)
glTexParameteri(GL_texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_state.Texture.GetTarget(), 0, GL_RGB8, wp2, hp2, 0, GL_BGR, GL_UNSIGNED_BYTE, NULL);
glTexImage2D(GL_state.Texture.GetTarget(), 0, GL_RGB8, g_screenWidth, g_screenHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, NULL);
}
GL_state.SetTextureSource(TEXTURE_SOURCE_DECAL);
GL_state.SetAlphaBlendMode(ALPHA_BLEND_NONE);
@@ -459,7 +452,7 @@ static void OGG_video_init(theora_info *tinfo)
}
if(!use_shaders) {
pixelbuf = (ubyte *) vm_malloc_q(g_screenWidth * g_screenHeight * 3);
pixelbuf = (ubyte *) vm_malloc(g_screenWidth * g_screenHeight * 3, memory::quiet_alloc);
if (pixelbuf == NULL) {
nprintf(("MOVIE", "ERROR: Can't allocate memory for pixelbuf"));
@@ -484,8 +477,8 @@ static void OGG_video_init(theora_info *tinfo)
gl_screenYH = g_screenY + g_screenHeight;
gl_screenXW = g_screenX + g_screenWidth;
gl_screenU = i2fl(g_screenWidth) / i2fl(wp2);
gl_screenV = i2fl(g_screenHeight) / i2fl(hp2);
gl_screenU = 1.f;
gl_screenV = 1.f;
if(use_shaders) {
gl_screenU = i2fl(tinfo->frame_width-1) / i2fl(2048) ;
@@ -658,6 +651,7 @@ static void OGG_video_draw(theora_state *tstate)
if(!use_shaders)
convert_YUV_to_RGB(&yuv);
if (gr_screen.mode == GR_OPENGL) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if(use_shaders) {
GL_state.Texture.SetActiveUnit(0);
glTexSubImage2D(GL_state.Texture.GetTarget(), 0, 0, 0, yuv.y_stride, yuv.y_height, GL_LUMINANCE, GL_UNSIGNED_BYTE, yuv.y);
@@ -743,7 +737,7 @@ THEORAFILE *theora_open(char *filename)
// create the file
movie = (THEORAFILE *) vm_malloc_q( sizeof(THEORAFILE) );
movie = (THEORAFILE *) vm_malloc( sizeof(THEORAFILE), memory::quiet_alloc);
if (movie == NULL)
return NULL;
+6 -4
View File
@@ -27,7 +27,7 @@ static inline int is_power_of_two(int w, int h)
}
int dds_read_header(const char *filename, CFILE *img_cfp, int *width, int *height, int *bpp, int *compression_type, int *levels, int *size, ubyte *palette)
int dds_read_header(const char *filename, CFILE *img_cfp, int *width, int *height, int *bpp, int *compression_type, int *levels, size_t *size, ubyte *palette)
{
DDSURFACEDESC2 dds_header;
int code = 0;
@@ -37,7 +37,8 @@ int dds_read_header(const char *filename, CFILE *img_cfp, int *width, int *heigh
int ct = DDS_UNCOMPRESSED;
int bits = 0;
int i, is_cubemap = 0;
int d_width = 0, d_height = 0, d_depth = 0, d_size = 0;
uint32_t d_width = 0, d_height = 0, d_depth = 0;
size_t d_size = 0;
if (img_cfp == NULL) {
@@ -276,7 +277,8 @@ int dds_read_bitmap(const char *filename, ubyte *data, ubyte *bpp, int cf_type)
{
int retval;
int w,h,ct,lvl;
int size = 0, bits = 0;
size_t size = 0;
int bits = 0;
CFILE *cfp;
char real_name[MAX_FILENAME_LEN];
@@ -308,7 +310,7 @@ int dds_read_bitmap(const char *filename, ubyte *data, ubyte *bpp, int cf_type)
cfseek(cfp, DDS_OFFSET, CF_SEEK_SET);
// read in the data
cfread(data, 1, size, cfp);
cfread(data, 1, (int)size, cfp);
if (bpp)
*bpp = (ubyte)bits;
+1 -1
View File
@@ -138,7 +138,7 @@ typedef struct _DDSURFACEDESC2
//reads a dds header
//returns one of the error values
//'compression_type' comes back as one of the DDS_DXTC* defines
int dds_read_header(const char *filename, CFILE *img_cfp = NULL, int *width = 0, int *height = 0, int *bpp = 0, int *compression_type = 0, int *levels = 0, int *size = 0, ubyte *palette = NULL);
int dds_read_header(const char *filename, CFILE *img_cfp = NULL, int *width = 0, int *height = 0, int *bpp = 0, int *compression_type = 0, int *levels = 0, size_t *size = 0, ubyte *palette = NULL);
//reads bitmap
//size of the data it stored in size
+22 -12
View File
@@ -49,7 +49,7 @@ int Debris_num_submodels = 0;
#define MAX_DEBRIS_DIST 10000.0f // Debris goes away if it's this far away.
#define DEBRIS_DISTANCE_CHECK_TIME (10*1000) // Check every 10 seconds.
#define DEBRIS_INDEX(dp) (dp-Debris)
#define DEBRIS_INDEX(dp) (int)(dp-Debris)
#define MAX_SPEED_SMALL_DEBRIS 200 // maximum velocity of small debris piece
#define MAX_SPEED_BIG_DEBRIS 150 // maximum velocity of big debris piece
@@ -78,7 +78,7 @@ static void debris_start_death_roll(object *debris_obj, debris *debris_p)
}
}
debris_obj->flags |= OF_SHOULD_BE_DEAD;
debris_obj->flags.set(Object::Object_Flags::Should_be_dead);
}
/**
@@ -201,7 +201,7 @@ void maybe_delete_debris(debris *db)
db->next_distance_check = timestamp(DEBRIS_DISTANCE_CHECK_TIME);
} else {
for ( objp = GET_FIRST(&obj_used_list); objp !=END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp) ) {
if (objp->flags & OF_PLAYER_SHIP) {
if (objp->flags[Object::Object_Flags::Player_ship]) {
if (vm_vec_dist_quick(&objp->pos, &Objects[db->objnum].pos) < MAX_DEBRIS_DIST) {
db->next_distance_check = timestamp(DEBRIS_DISTANCE_CHECK_TIME);
return;
@@ -378,7 +378,7 @@ int debris_find_oldest()
oldest_time = 0x7fffffff;
for ( db = GET_FIRST(&Hull_debris_list); db != END_OF_LIST(&Hull_debris_list); db = GET_NEXT(db) ) {
if ( (db->time_started < oldest_time) && !(Objects[db->objnum].flags & OF_SHOULD_BE_DEAD) ) {
if ( (db->time_started < oldest_time) && !(Objects[db->objnum].flags[Object::Object_Flags::Should_be_dead]) ) {
oldest_index = DEBRIS_INDEX(db);
oldest_time = db->time_started;
}
@@ -418,7 +418,7 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
Assert( source_obj->instance >= 0 && source_obj->instance < MAX_SHIPS );
shipp = &Ships[source_obj->instance];
sip = &Ship_info[shipp->ship_info_index];
vaporize = (shipp->flags &SF_VAPORIZE);
vaporize = (shipp->flags[Ship::Ship_Flags::Vaporize]);
if ( !hull_flag ) {
// Make vaporize debris seen from farther away
@@ -548,10 +548,12 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
if ( pos == NULL )
pos = &source_obj->pos;
uint flags = OF_RENDERS | OF_PHYSICS;
if ( hull_flag )
flags |= OF_COLLIDES;
objnum = obj_create( OBJ_DEBRIS, parent_objnum, n, &source_obj->orient, pos, radius, flags );
flagset<Object::Object_Flags> default_flags;
default_flags.set(Object::Object_Flags::Renders);
default_flags.set(Object::Object_Flags::Physics);
default_flags.set(Object::Object_Flags::Collides, hull_flag != 0);
objnum = obj_create( OBJ_DEBRIS, parent_objnum, n, &source_obj->orient, pos, radius, default_flags);
if ( objnum == -1 ) {
mprintf(("Couldn't create debris object -- out of object slots\n"));
return NULL;
@@ -696,7 +698,7 @@ void debris_hit(object *debris_obj, object *other_obj, vec3d *hitpos, float dama
// Do a little particle spark shower to show we hit
{
particle_emitter pe;
particle::particle_emitter pe;
pe.pos = *hitpos; // Where the particles emit from
pe.vel = debris_obj->phys_info.vel; // Initial velocity of all the particles
@@ -718,7 +720,7 @@ void debris_hit(object *debris_obj, object *other_obj, vec3d *hitpos, float dama
pe.max_vel = 10.0f; // How fast the fastest particle can move
pe.min_life = 0.25f; // How long the particles live
pe.max_life = 0.75f; // How long the particles live
particle_emit( &pe, PARTICLE_FIRE, 0 );
particle::emit( &pe, particle::PARTICLE_FIRE, 0 );
}
// multiplayer clients bail here
@@ -747,7 +749,7 @@ void debris_hit(object *debris_obj, object *other_obj, vec3d *hitpos, float dama
* NOTE: debris_hit_info pointer NULL for debris:weapon collision, otherwise debris:ship collision.
* @return true if hit, else return false.
*/
int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, collision_info_struct *debris_hit_info)
int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, collision_info_struct *debris_hit_info, vec3d* hitNormal)
{
mc_info mc;
mc_info_init(&mc);
@@ -776,6 +778,14 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
if (model_collide(&mc)) {
*hitpos = mc.hit_point_world;
if (hitNormal)
{
vec3d normal;
model_find_world_dir(&normal, &mc.hit_normal, mc.model_num, mc.hit_submodel, mc.orient);
*hitNormal = normal;
}
}
weapon *wp = &Weapons[other_obj->instance];
+1 -1
View File
@@ -67,7 +67,7 @@ void debris_render(object * obj, draw_list *scene);
void debris_delete( object * obj );
void debris_process_post( object * obj, float frame_time);
object *debris_create( object * source_obj, int model_num, int submodel_num, vec3d *pos, vec3d *exp_center, int hull_flag, float exp_force );
int debris_check_collision( object * obj, object * other_obj, vec3d * hitpos, collision_info_struct *debris_hit_info=NULL );
int debris_check_collision( object * obj, object * other_obj, vec3d * hitpos, collision_info_struct *debris_hit_info=NULL, vec3d* hitnormal = NULL );
void debris_hit( object * debris_obj, object * other_obj, vec3d * hitpos, float damage );
int debris_get_team(object *objp);
void debris_clear_expired_flag(debris *db);
+24 -17
View File
@@ -36,7 +36,7 @@ uint lastline = 0; // Number of lines written to the console since the last com
// Text Buffer
uint DBROWS = 80; // # of buffer rows
uint DBCOLS = 80; // # of buffer columns
uint lastwhite = 0; // Last whitespace character encountered, used by putc for 'true' word wrapping
size_t lastwhite = 0; // Last whitespace character encountered, used by putc for 'true' word wrapping
ubyte DTABS = 4; //!< Tab size in spaces
/**
@@ -66,7 +66,7 @@ uint dc_scroll_x; // X scroll position (Leftmost character)
uint dc_scroll_y; // Y scroll position (Topmost character)
int row_height; // Row/Line height, in pixels
int col_width; // Col/Character width, in pixels
int dc_font = FONT1;
int dc_font = font::FONT1;
SCP_string dc_title;
@@ -185,9 +185,12 @@ void dc_do_command(SCP_string *cmd_str)
void dc_draw(bool show_prompt = FALSE)
{
gr_clear();
gr_set_font(dc_font);
font::set_font(dc_font);
gr_set_color_fast( &Color_bright );
gr_string( 0x8000, gr_screen.center_offset_y + 3, dc_title.c_str(), GR_RESIZE_NONE );
int w;
gr_get_string_size(&w, nullptr, dc_title.c_str());
gr_string((gr_screen.clip_width - w) / 2, 3, dc_title.c_str(), GR_RESIZE_NONE );
gr_set_color_fast( &Color_normal );
@@ -205,18 +208,19 @@ void dc_draw_cursor( SCP_string &cmd_string, int x, int y )
if ( t & 1 ) {
gr_get_string_size( &w, &h, cmd_string.c_str() );
w %= (DCOLS * Current_font->w);
w %= (DCOLS * col_width);
//gr_string( w, debug_y*16, "_" );
gr_rect(gr_screen.center_offset_x + (x + (w + 1)), gr_screen.center_offset_y + (y + (h + 1)), 2, Current_font->h, GR_RESIZE_NONE);
gr_rect(gr_screen.center_offset_x + (x + (w + 1)), gr_screen.center_offset_y + (y + (h + 1)), 2,
fl2i(font::get_current_font()->getHeight()), GR_RESIZE_NONE);
}
}
void dc_draw_window(bool show_prompt)
{
uint cmd_lines; // Number of lines for the command string
uint buffer_lines; // Number of lines from the buffer to draw
uint i; // The current row we're drawing
uint j; // The current row of the command string we're drawing
size_t cmd_lines; // Number of lines for the command string
size_t buffer_lines; // Number of lines from the buffer to draw
size_t i; // The current row we're drawing
size_t j; // The current row of the command string we're drawing
SCP_string out_str; // The command string + prompt character
SCP_string::iterator str_it; // Iterator to out_str
@@ -235,7 +239,7 @@ void dc_draw_window(bool show_prompt)
// Ensure we don't scroll too far
dc_scroll_x = MIN(dc_scroll_x, (DBCOLS - DCOLS));
if (dc_buffer.size() >= buffer_lines) {
dc_scroll_y = MIN(dc_scroll_y, (dc_buffer.size() - buffer_lines));
dc_scroll_y = MIN(dc_scroll_y, (uint32_t)(dc_buffer.size() - buffer_lines));
} else {
dc_scroll_y = 0; // Disallow vscroll until the buffer is larger than the window
}
@@ -243,7 +247,7 @@ void dc_draw_window(bool show_prompt)
// Draw the buffer strings
for (i = 0; i < buffer_lines; ++i) {
if ((i + dc_scroll_y) < dc_buffer.size()) {
gr_string(gr_screen.center_offset_x, gr_screen.center_offset_y + ((i * row_height) + row_height), dc_buffer[i + dc_scroll_y].substr(dc_scroll_x).c_str(), GR_RESIZE_NONE);
gr_string(gr_screen.center_offset_x, gr_screen.center_offset_y + (((int)i * row_height) + row_height), dc_buffer[i + dc_scroll_y].substr(dc_scroll_x).c_str(), GR_RESIZE_NONE);
}
}
@@ -261,9 +265,9 @@ void dc_draw_window(bool show_prompt)
++j;
}
}
gr_string(gr_screen.center_offset_x, gr_screen.center_offset_y + ((i * row_height) + row_height), out_str.c_str(), GR_RESIZE_NONE);
gr_string(gr_screen.center_offset_x, gr_screen.center_offset_y + (((int)i * row_height) + row_height), out_str.c_str(), GR_RESIZE_NONE);
dc_draw_cursor(out_str, 0, ((i * row_height)));
dc_draw_cursor(out_str, 0, (((int)i * row_height)));
gr_set_color_fast(&Color_normal);
}
}
@@ -277,9 +281,12 @@ void dc_init(void)
debug_inited = TRUE;
// Init window settings
dc_font = FONT1;
row_height = ((Current_font->h) * 3) / 2; // Row/Line height, in pixels
col_width = Current_font->w; // Col/Character width, in pixels
dc_font = font::FONT1;
row_height = ((fl2i(font::get_current_font()->getHeight())) * 3) / 2; // Row/Line height, in pixels
// This assumes that FONT1 is monospaced!
gr_get_string_size(&col_width, nullptr, " "); // Col/Character width, in pixels
dc_scroll_x = 0;
dc_scroll_y = 0;
DCOLS = (gr_screen.center_w / col_width) - 1; // Subtract as needed. Windowed mode has some quirks with the resolution
+8 -6
View File
@@ -76,10 +76,10 @@ void fireball_play_warphole_open_sound(int ship_class, fireball *fb)
if(fb->warp_open_sound_index > -1) {
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].flags & SIF_HUGE_SHIP ) {
if ( Ship_info[ship_class].is_huge_ship() ) {
sound_index = SND_CAPITAL_WARP_IN;
fb->flags |= FBF_WARP_CAPITAL_SIZE;
} else if ( Ship_info[ship_class].flags & SIF_BIG_SHIP ) {
} else if ( Ship_info[ship_class].is_big_ship() ) {
range_multiplier = 6.0f;
fb->flags |= FBF_WARP_CRUISER_SIZE;
}
@@ -462,7 +462,7 @@ int fireball_is_perishable(object * obj)
return 1;
if ( !(fb->fireball_render_type == FIREBALL_WARP_EFFECT) ) {
if ( !(obj->flags & OF_WAS_RENDERED)) {
if ( !(obj->flags[Object::Object_Flags::Was_rendered])) {
return 1;
}
}
@@ -564,7 +564,7 @@ void fireball_process_post(object * obj, float frame_time)
fb->time_elapsed += frame_time;
if ( fb->time_elapsed > fb->total_time ) {
obj->flags |= OF_SHOULD_BE_DEAD;
obj->flags.set(Object::Object_Flags::Should_be_dead);
}
fireball_maybe_play_warp_close_sound(fb);
@@ -767,7 +767,9 @@ int fireball_create( vec3d * pos, int fireball_type, int render_type, int parent
}
}
objnum = obj_create(OBJ_FIREBALL, parent_obj, n, &orient, pos, size, OF_RENDERS);
flagset<Object::Object_Flags> default_flags;
default_flags.set(Object::Object_Flags::Renders);
objnum = obj_create(OBJ_FIREBALL, parent_obj, n, &orient, pos, size, default_flags);
if (objnum < 0) {
Int3(); // Get John, we ran out of objects for fireballs
@@ -825,7 +827,7 @@ int fireball_create( vec3d * pos, int fireball_type, int render_type, int parent
if ( velocity ) {
// Make the explosion move at a constant velocity.
obj->flags |= OF_PHYSICS;
obj->flags.set(Object::Object_Flags::Physics);
obj->phys_info.mass = 1.0f;
obj->phys_info.side_slip_time_const = 0.0f;
obj->phys_info.rotdamp = 0.0f;
+2 -2
View File
@@ -114,7 +114,7 @@ void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_n
g3_transfer_vertex( &verts[4], &vecs[4] );
float alpha = (The_mission.flags & MISSION_FLAG_FULLNEB) ? (1.0f - neb2_get_fog_intensity(obj)) : 1.0f;
float alpha = (The_mission.flags[Mission::Mission_Flags::Fullneb]) ? (1.0f - neb2_get_fog_intensity(obj)) : 1.0f;
gr_set_bitmap( Warp_glow_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, alpha );
g3_draw_bitmap( &verts[4], 0, r, TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT );
@@ -252,7 +252,7 @@ void warpin_queue_render(draw_list *scene, object *obj, matrix *orient, vec3d *p
g3_transfer_vertex( &verts[4], &vecs[4] );
float alpha = (The_mission.flags & MISSION_FLAG_FULLNEB) ? (1.0f - neb2_get_fog_intensity(obj)) : 1.0f;
float alpha = (The_mission.flags[Mission::Mission_Flags::Fullneb]) ? (1.0f - neb2_get_fog_intensity(obj)) : 1.0f;
batch_add_bitmap(Warp_glow_bitmap, TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT | TMAP_FLAG_EMISSIVE , &verts[4], 0, r, alpha);
}
+1 -1
View File
@@ -1295,7 +1295,7 @@ int fs2netd_get_valid_missions_do()
if (file_names == NULL) {
// allocate filename space
file_names = (char**) vm_malloc_q( sizeof(char*) * 1024 ); // 1024 files should be safe!
file_names = (char**) vm_malloc( sizeof(char*) * 1024, memory::quiet_alloc); // 1024 files should be safe!
if (file_names == NULL) {
Local_timeout = -1;
+15 -5
View File
@@ -571,7 +571,9 @@ void FS2NetD_SendServerStart()
DONE_PACKET();
FS2NetD_SendData(buffer, buffer_size);
if (FS2NetD_SendData(buffer, buffer_size) < 0) {
ml_printf("FS2NetD WARNING: Failed to send server start packet!");
}
}
void FS2NetD_SendServerUpdate()
@@ -596,7 +598,9 @@ void FS2NetD_SendServerUpdate()
DONE_PACKET();
FS2NetD_SendData(buffer, buffer_size);
if (FS2NetD_SendData(buffer, buffer_size) < 0) {
ml_printf("FS2NetD WARNING: Failed to send server update packet!");
}
}
void FS2NetD_SendServerDisconnect()
@@ -608,7 +612,9 @@ void FS2NetD_SendServerDisconnect()
DONE_PACKET();
FS2NetD_SendData(buffer, buffer_size);
if (FS2NetD_SendData(buffer, buffer_size) < 0) {
ml_printf("FS2NetD WARNING: Failed to send server disconnect packet!");
}
}
void FS2NetD_RequestServerList()
@@ -649,7 +655,9 @@ void FS2NetD_Ping()
DONE_PACKET();
FS2NetD_SendData(buffer, buffer_size);
if (FS2NetD_SendData(buffer, buffer_size) < 0) {
ml_printf("Failed to send PING packet!");
}
}
void FS2NetD_Pong(int tstamp)
@@ -832,7 +840,9 @@ void FS2NetD_CheckDuplicateLogin()
DONE_PACKET();
FS2NetD_SendData(buffer, buffer_size);
if (FS2NetD_SendData(buffer, buffer_size) < 0) {
ml_printf("FS2NetD WARNING: Failed to send data packet to server!");
}
delete [] ids;
}
+1 -1
View File
@@ -61,7 +61,7 @@ void FS2NetD_Pong(int tstamp);
#define PXO_ADD_USHORT(d) do { Assert(buffer_size+sizeof(ushort) <= sizeof(buffer)); ushort swap = INTEL_SHORT(d); memcpy(buffer+buffer_size, &swap, sizeof(ushort)); buffer_size += sizeof(ushort); } while (0)
#define PXO_ADD_INT(d) do { Assert(buffer_size+sizeof(int) <= sizeof(buffer)); int swap = INTEL_INT(d); memcpy(buffer+buffer_size, &swap, sizeof(int)); buffer_size += sizeof(int); } while (0)
#define PXO_ADD_UINT(d) do { Assert(buffer_size+sizeof(uint) <= sizeof(buffer)); uint swap = INTEL_INT(d); memcpy(buffer+buffer_size, &swap, sizeof(uint)); buffer_size += sizeof(uint); } while (0)
#define PXO_ADD_STRING(s) do { Assert(buffer_size+strlen(s)+sizeof(int) <= sizeof(buffer)); int len = strlen(s); PXO_ADD_INT(len); if (len > 0) { memcpy(buffer+buffer_size, s, len ); buffer_size += len; } } while(0)
#define PXO_ADD_STRING(s) do { Assert(buffer_size+strlen(s)+sizeof(int) <= sizeof(buffer)); int len = (int)strlen(s); PXO_ADD_INT(len); if (len > 0) { memcpy(buffer+buffer_size, s, len ); buffer_size += len; } } while(0)
#define PXO_GET_DATA(d) do { Assert(buffer_offset+sizeof(d) <= sizeof(buffer)); memcpy(&d, buffer+buffer_offset, sizeof(d) ); buffer_offset += sizeof(d); } while(0)
#define PXO_GET_SHORT(d) do { Assert(buffer_offset+sizeof(short) <= sizeof(buffer)); short swap; memcpy(&swap, buffer+buffer_offset, sizeof(short) ); d = INTEL_SHORT(swap); buffer_offset += sizeof(short); } while(0)
+2 -2
View File
@@ -190,7 +190,7 @@ int FS2NetD_ConnectToServer(const char *host, const char *port)
FD_SET(mySocket, &write_fds);
// if it's writeable then we are fully connected
if ( select(mySocket+1, NULL, &write_fds, NULL, &timeout) > 0 ) {
if ( select(static_cast<int>(mySocket + 1), NULL, &write_fds, NULL, &timeout) > 0 ) {
// make sure that we don't have any connect() errors (since it's non-blocking)
int err_val = 0;
size_t err_val_size = sizeof(err_val);
@@ -213,7 +213,7 @@ int FS2NetD_ConnectToServer(const char *host, const char *port)
FD_SET(mySocket, &error_fds);
// if it's in error then it has failed to connect
if ( select(mySocket+1, NULL, NULL, &error_fds, &timeout) )
if ( select(static_cast<int>(mySocket + 1), NULL, NULL, &error_fds, &timeout) )
return -1;
// not connected, and haven't failed to connect, so keep in the loop
+4 -4
View File
@@ -396,7 +396,7 @@ void parse_helptbl(const char *filename)
}
else {
for (i = 0; i < help_overlaylist[overlay_id].num_resolutions; i++) {
help_overlaylist[overlay_id].fontlist.push_back(FONT1);
help_overlaylist[overlay_id].fontlist.push_back(font::FONT1);
}
}
@@ -511,15 +511,15 @@ void help_overlay_blit(int overlay_id, int resolution_index)
Assert(overlay_id >= 0 && overlay_id < MAX_HELP_OVERLAYS);
// this draws each line of help text with white on black text (use the first resolution index for the string)
gr_set_font(help_overlaylist[overlay_id].fontlist.at(resolution_index));
font::set_font(help_overlaylist[overlay_id].fontlist.at(resolution_index));
for (idx = 0; idx < textcount; idx++) {
gr_set_color_fast(&Color_black);
gr_get_string_size(&width, &height, help_overlaylist[overlay_id].textlist.at(0).at(idx).string, strlen(help_overlaylist[overlay_id].textlist.at(0).at(idx).string));
gr_get_string_size(&width, &height, help_overlaylist[overlay_id].textlist.at(0).at(idx).string, (int)strlen(help_overlaylist[overlay_id].textlist.at(0).at(idx).string));
gr_rect(help_overlaylist[overlay_id].textlist.at(resolution_index).at(idx).x_coord-2*HELP_PADDING, help_overlaylist[overlay_id].textlist.at(resolution_index).at(idx).y_coord-3*HELP_PADDING, width+4*HELP_PADDING, height+4*HELP_PADDING, GR_RESIZE_MENU);
gr_set_color_fast(&Color_bright_white);
gr_printf_menu(help_overlaylist[overlay_id].textlist.at(resolution_index).at(idx).x_coord, help_overlaylist[overlay_id].textlist.at(resolution_index).at(idx).y_coord, help_overlaylist[overlay_id].textlist.at(0).at(idx).string);
}
gr_set_font(FONT1);
font::set_font(font::FONT1);
// this draws each right bracket
for (idx = 0; idx < rbracketcount; idx++) {
+45 -33
View File
@@ -189,9 +189,14 @@ void gameplay_help_set_title(const char *title)
char buf[128];
gr_set_color_fast(&Color_bright);
gr_printf_menu(0x8000,sy,title);
sprintf(buf, XSTR( "Page %d of %d", 132), Current_help_page+1, Gp_last_screen+1);
gr_printf_menu(0x8000,sy+gr_get_font_height()+2,buf);
int w;
gr_get_string_size(&w, NULL, title);
gr_printf_menu((gr_screen.clip_width_unscaled - w) / 2,sy,title);
sprintf(buf, XSTR("Page %d of %d", 132), Current_help_page + 1, Gp_last_screen + 1);
gr_get_string_size(&w, NULL, buf);
gr_printf_menu((gr_screen.clip_width_unscaled - w) / 2, sy + gr_get_font_height() + 2, buf);
gr_set_color_fast(&Color_normal);
}
@@ -335,60 +340,63 @@ void gameplay_help_draw_text()
switch ( Current_help_page ) {
case GP_HELP_BASIC_KEYS:
gameplay_help_set_title(XSTR( "Basic Keys", 133));
x_offset=X_OFFSET_1;
y_offset=Y_START;
{
gameplay_help_set_title(XSTR("Basic Keys", 133));
x_offset = X_OFFSET_1;
y_offset = Y_START;
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset,END_MISSION);
gameplay_help_blit_control_line(x_offset, y_offset, END_MISSION);
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset,FIRE_PRIMARY);
gameplay_help_blit_control_line(x_offset, y_offset, FIRE_PRIMARY);
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset,MAX_THROTTLE);
gameplay_help_blit_control_line(x_offset, y_offset, MAX_THROTTLE);
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset,ZERO_THROTTLE);
gameplay_help_blit_control_line(x_offset, y_offset, ZERO_THROTTLE);
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset,TARGET_NEXT);
gameplay_help_blit_control_line(x_offset, y_offset, TARGET_NEXT);
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset,TARGET_PREV);
gameplay_help_blit_control_line(x_offset, y_offset, TARGET_PREV);
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset,TOGGLE_AUTO_TARGETING);
gameplay_help_blit_control_line(x_offset, y_offset, TOGGLE_AUTO_TARGETING);
y_offset += separation;
y_offset += separation;
gr_set_color_fast(&Color_bright);
gr_printf_menu(0x8000,y_offset,XSTR( "Function Keys", 134));
int w;
gr_get_string_size(&w, NULL, XSTR("Function Keys", 134));
gr_printf_menu((gr_screen.clip_width - w) / 2, y_offset, XSTR("Function Keys", 134));
gr_set_color_fast(&Color_normal);
y_offset += separation;
y_offset += separation;
gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "F1", 135), XSTR( "context-sensitive help", 136));
gameplay_help_blit_control_line_raw(x_offset, y_offset, XSTR("F1", 135), XSTR("context-sensitive help", 136));
y_offset += separation;
gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "F2", 137), XSTR( "options screen (available anywhere in game)", 138));
gameplay_help_blit_control_line_raw(x_offset, y_offset, XSTR("F2", 137), XSTR("options screen (available anywhere in game)", 138));
y_offset += separation;
gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "F3", 139), XSTR( "hotkey assignment", 140));
gameplay_help_blit_control_line_raw(x_offset, y_offset, XSTR("F3", 139), XSTR("hotkey assignment", 140));
y_offset += separation;
gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "F4", 141), XSTR( "HUD message scroll-back", 142));
gameplay_help_blit_control_line_raw(x_offset, y_offset, XSTR("F4", 141), XSTR("HUD message scroll-back", 142));
y_offset += separation;
gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "F5...F12", 143), XSTR( "hotkeys", 144));
gameplay_help_blit_control_line_raw(x_offset, y_offset, XSTR("F5...F12", 143), XSTR("hotkeys", 144));
y_offset += separation;
gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "Shift-Esc", 145), XSTR( "quit FreeSpace 2 immediately", 146));
gameplay_help_blit_control_line_raw(x_offset, y_offset, XSTR("Shift-Esc", 145), XSTR("quit FreeSpace 2 immediately", 146));
break;
}
case GP_HELP_MOVEMENT_KEYS:
gameplay_help_set_title(XSTR( "Movement Keys", 147));
x_offset=X_OFFSET_1;
@@ -749,30 +757,34 @@ void gameplay_help_draw_text()
break;
case GP_HELP_MULTI_KEYS:
gameplay_help_set_title(XSTR( "Multiplayer Keys", 167));
x_offset=X_OFFSET_1;
y_offset=Y_START;
{
gameplay_help_set_title(XSTR("Multiplayer Keys", 167));
x_offset = X_OFFSET_1;
y_offset = Y_START;
// ingame messaging
gr_set_color_fast(&Color_bright);
gr_printf_menu(0x8000,y_offset,XSTR( "Ingame messaging keys (tap for text, hold for voice)", 168));
int w;
gr_get_string_size(&w, NULL, XSTR("Ingame messaging keys (tap for text, hold for voice)", 168));
gr_printf_menu((gr_screen.clip_width - w) / 2, y_offset, XSTR("Ingame messaging keys (tap for text, hold for voice)", 168));
gr_set_color_fast(&Color_normal);
y_offset += separation;
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset,MULTI_MESSAGE_ALL);
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset,MULTI_MESSAGE_FRIENDLY);
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset,MULTI_MESSAGE_HOSTILE);
gameplay_help_blit_control_line(x_offset, y_offset, MULTI_MESSAGE_ALL);
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset,MULTI_MESSAGE_TARGET);
gameplay_help_blit_control_line(x_offset, y_offset, MULTI_MESSAGE_FRIENDLY);
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset, MULTI_MESSAGE_HOSTILE);
y_offset += separation;
gameplay_help_blit_control_line(x_offset, y_offset, MULTI_MESSAGE_TARGET);
break;
}
} // end switch
}
+3 -3
View File
@@ -1619,11 +1619,11 @@ int hostile_ships_present()
continue;
// check if ship is threatening
if ( (shipp->flags & (SF_DISABLED|SF_DYING|SF_DEPARTING)) || (ship_subsys_disrupted(shipp, SUBSYSTEM_ENGINE)) )
if ( shipp->is_dying_or_departing() || shipp->flags[Ship::Ship_Flags::Disabled] || (ship_subsys_disrupted(shipp, SUBSYSTEM_ENGINE)) )
continue;
// check if ship is flyable
if ( Ship_info[shipp->ship_info_index].flags & SIF_NOT_FLYABLE ) {
if (!Ship_info[shipp->ship_info_index].is_flyable()) {
continue;
}
@@ -1652,7 +1652,7 @@ int hostile_ships_to_arrive()
for (p_objp = GET_FIRST(&Ship_arrival_list); p_objp != END_OF_LIST(&Ship_arrival_list); p_objp = GET_NEXT(p_objp))
{
// check if ship can arrive
if (p_objp->flags & P_SF_CANNOT_ARRIVE)
if (p_objp->flags[Mission::Parse_Object_Flags::SF_Cannot_arrive])
continue;
// check if ship is enemy ship (we attack it)
-2
View File
@@ -8,10 +8,8 @@
*/
#include "globalincs/alphacolors.h"
#include "def_files/def_files.h"
#include "graphics/2d.h"
#include "parse/parselo.h"
#include "def_files/def_files.h"
SCP_map<SCP_string, team_color> Team_Colors;
SCP_vector<SCP_string> Team_Names;
-1
View File
@@ -13,7 +13,6 @@
#include "def_files/def_files.h"
#include "graphics/2d.h"
#include "parse/parselo.h"
#include "def_files/def_files.h"
// -----------------------------------------------------------------------------------
// ALPHA DEFINES/VARS
File diff suppressed because it is too large. Load diff
+124
View File
@@ -0,0 +1,124 @@
#ifndef _FLAGSET_
#define _FLAGSET_
#include <bitset>
#include <cstdint>
template <class T, size_t SIZE = static_cast < size_t >(T::NUM_VALUES)>
class flagset {
protected:
std::bitset<SIZE> values;
public:
flagset() {}
flagset(const std::initializer_list<T>& init_list) {
for (auto& val : init_list) {
set(val);
}
}
bool operator [] (const T idx) const { return values[(static_cast < size_t >(idx))]; };
flagset<T> operator & (const flagset<T>& other) const {
flagset<T> result;
result.values = this->values & other.values;
return result;
}
flagset<T> operator + (const T flag) const {
flagset<T> result = *this;
result.set(flag);
return result;
}
flagset<T>& operator += (const T flag) {
this->set(flag);
return *this;
}
flagset<T> operator - (const T flag) const {
flagset<T> result = *this;
result.remove(flag);
return result;
}
flagset<T>& operator -= (const T flag) {
this->remove(flag);
return *this;
}
flagset<T> operator | (const flagset<T>& other) const {
flagset<T> result;
result.values = this->values | other.values;
return result;
}
flagset<T>& operator |= (const flagset<T>& other) {
this->values |= other.values;
return *this;
}
void operator |= (const T flag) {
set(flag);
}
bool operator == (const flagset<T>& other) const { return this->values == other.values; }
bool operator != (const flagset<T>& other) const { return this->values != other.values; }
void reset() { values.reset(); }
flagset<T>& set(T idx, bool value = true) {
Assertion(static_cast<size_t>(idx) < values.size(), "Invalid value passed to flagset::set(), get a stacktrace, a coder, an old priest and a young priest.");
values.set(static_cast < size_t >(idx), value);
return *this;
}
template<typename TIter>
flagset<T>& set_multiple(TIter begin, TIter end) {
auto current = begin;
while (current != end)
{
set(*current, true);
current = std::next(current);
}
return *this;
}
flagset<T>& remove(T idx) {
return set(idx, false);
}
template<typename TIter>
flagset<T>& remove_multiple(TIter begin, TIter end) {
auto current = begin;
while (current != end)
{
set(*current, false);
current = std::next(current);
}
return *this;
}
flagset<T>& toggle(T idx) {
values[static_cast < size_t >(idx)] = !values[static_cast < size_t >(idx)];
return *this;
}
bool any_set() const { return values.any(); }
bool none_set() const { return values.none(); }
void from_long(std::uint64_t num) { values = num; }
std::uint64_t to_long() const { return values.to_ulong(); }
};
#define FLAG_LIST(Type) enum class Type : size_t
#endif
-57
View File
@@ -1,57 +0,0 @@
#include "globalincs/pstypes.h"
// throw
void * operator new (size_t size)
{
void *p = vm_malloc_q(size);
if ( !p ) {
throw std::bad_alloc();
}
return p;
}
void operator delete (void *p) throw()
{
vm_free(p);
}
void * operator new [] (size_t size)
{
void *p = vm_malloc_q(size);
if ( !p ) {
throw std::bad_alloc();
}
return p;
}
void operator delete [] (void *p) throw()
{
vm_free(p);
}
// no-throw
void * operator new (size_t size, const std::nothrow_t&) throw()
{
return vm_malloc_q(size);
}
void operator delete (void *p, const std::nothrow_t&) throw()
{
vm_free(p);
}
void * operator new [] (size_t size, const std::nothrow_t&) throw()
{
return vm_malloc_q(size);
}
void operator delete [] (void *p, const std::nothrow_t&) throw()
{
vm_free(p);
}
+7 -18
View File
@@ -2,24 +2,13 @@
#ifndef _FSMEMORY_H
#define _FSMEMORY_H
#include <new>
#ifndef NDEBUG
#include "globalincs/memory/debug.h"
#else
#include "globalincs/memory/release.h"
#endif
// throw
extern void * operator new (size_t size);
extern void operator delete (void *p) throw();
extern void * operator new [] (size_t size);
extern void operator delete [] (void *p) throw();
// no-throw
extern void * operator new (size_t size, const std::nothrow_t&) throw();
extern void operator delete (void *p, const std::nothrow_t&) throw();
extern void * operator new [] (size_t size, const std::nothrow_t&) throw();
extern void operator delete [] (void *p, const std::nothrow_t&) throw();
#include "globalincs/memory/memory.h"
#include "globalincs/memory/utils.h"
#endif // _FSMEMORY_H
+43
View File
@@ -0,0 +1,43 @@
#ifndef NDEBUG
#include "debug.h"
#include "globalincs/pstypes.h"
// Generic non-quiet version that just call the specialized versions
void *_vm_malloc(size_t size, const char *filename, int line)
{
auto ptr = _vm_malloc(size, memory::quiet_alloc, filename, line);
if (ptr == nullptr)
{
memory::out_of_memory(filename, line);
}
return ptr;
}
void *_vm_realloc(void *ptr, size_t size, const char *filename, int line)
{
auto ret_ptr = _vm_realloc(ptr, size, memory::quiet_alloc, filename, line);
if (ret_ptr == nullptr)
{
memory::out_of_memory(filename, line);
}
return ret_ptr;
}
void* malloc_location(size_t size, const char* location, int line)
{
return _vm_malloc(size, location, line);
}
void free_location(void* ptr, const char* location, int line)
{
_vm_free(ptr, location, line);
}
#endif
+43
View File
@@ -0,0 +1,43 @@
#pragma once
#ifdef NDEBUG
#error Debug memory management header included in release build!
#endif
#include <stdexcept>
#include "globalincs/memory/memory.h"
#include "globalincs/scp_defines.h"
namespace memory
{
// Called to initialize memory tracking in debug builds
void debug_init();
void debug_exit();
}
// Allocates some RAM.
void *_vm_malloc(size_t size, const char *filename, int line);
void *_vm_malloc(size_t size, const memory::quiet_alloc_t&, const char *filename, int line);
// Frees some RAM.
void _vm_free(void *ptr, const char *filename, int line);
// reallocates some RAM
void *_vm_realloc(void *ptr, size_t size, const char *filename, int line);
void *_vm_realloc(void *ptr, size_t size, const memory::quiet_alloc_t&, const char *filename, int line);
// Easy to use macros
#define vm_malloc(...) _vm_malloc(__VA_ARGS__,__FILE__,__LINE__)
#define vm_free(...) _vm_free(__VA_ARGS__,__FILE__,__LINE__)
#define vm_realloc(...) _vm_realloc(__VA_ARGS__,__FILE__,__LINE__)
// Version with explicit location information
void* malloc_location(size_t size, const char* location, int line);
void free_location(void* ptr, const char* location, int line);
// untracked versions DON'T USE IN NORMAL CODE!!
void* malloc_untracked(size_t size);
void free_untracked(void* ptr);
+126
View File
@@ -0,0 +1,126 @@
#ifndef NDEBUG
#include <cstdlib>
#include <stdlib.h>
// Include this first!
#include "globalincs/memory/debug.h"
#include "globalincs/pstypes.h"
namespace
{
struct MemoryHeader
{
const char *filename;
int line;
size_t size;
};
void *getMemoryBegin(void *ptr)
{
auto headerArray = reinterpret_cast<MemoryHeader *>(ptr);
// The pointer should point to the beginning of the actual memory block
// the memory header is directly "in front" of it
return reinterpret_cast<void *>(headerArray - 1);
}
}
namespace memory
{
// Called to initialize memory tracking in debug builds
void debug_init()
{
// Do nothing in the generic version
}
void debug_exit()
{
// Do nothing in the generic version
}
}
void *_vm_malloc(size_t size, const memory::quiet_alloc_t &, const char *filename, int line)
{
auto ptr = std::malloc(sizeof(MemoryHeader) + size);
if (ptr != nullptr)
{
memory::register_malloc(size, filename, line);
auto header = reinterpret_cast<MemoryHeader *>(ptr);
header->size = size;
header->filename = filename;
header->line = line;
ptr = reinterpret_cast<void *>(header + 1);
}
return ptr;
}
void _vm_free(void *ptr, const char *filename, int line)
{
if (!ptr)
{
return;
}
ptr = getMemoryBegin(ptr);
auto header = reinterpret_cast<MemoryHeader *>(ptr);
memory::unregister_malloc(header->size, header->filename, header->line);
std::free(ptr);
}
void *_vm_realloc(void *ptr, size_t size, const memory::quiet_alloc_t &, const char *filename, int line)
{
if (ptr == nullptr)
{
return _vm_malloc(size, filename, line);
}
ptr = getMemoryBegin(ptr);
auto memoryHeader = reinterpret_cast<MemoryHeader *>(ptr);
auto oldSize = memoryHeader->size;
auto oldFilename = memoryHeader->filename;
auto oldLine = memoryHeader->line;
auto ret_ptr = std::realloc(ptr, sizeof(MemoryHeader) + size);
if (ret_ptr == nullptr)
{
// realloc doesn't touch the original ptr in the case of failure so we could still use it
return nullptr;
}
memory::unregister_malloc(oldSize, oldFilename, oldLine);
auto header = reinterpret_cast<MemoryHeader *>(ret_ptr);
header->filename = filename;
header->line = line;
header->size = size;
memory::register_malloc(size, filename, line);
return reinterpret_cast<void *>(header + 1);
}
void *malloc_untracked(size_t size)
{
return std::malloc(size);
}
void free_untracked(void *ptr)
{
std::free(ptr);
}
#endif
+144
View File
@@ -0,0 +1,144 @@
// Only compile in debug builds
#ifndef NDEBUG
#include "debug.h"
#include "globalincs/pstypes.h"
#include <crtdbg.h>
namespace
{
const int UNTRACKED_SUBTYPE = 5;
const int UNTRACKED_BLOCK = _CLIENT_BLOCK | (UNTRACKED_SUBTYPE << 16);
// From https://msdn.microsoft.com/en-us/library/974tc9t1.aspx
// IMPORTANT: For some reason the MS documentation is wrong, the nBlockUse and nDataSize fields are switched
typedef struct _CrtMemBlockHeader
{
// Pointer to the block allocated just before this one:
struct _CrtMemBlockHeader *pBlockHeaderNext;
// Pointer to the block allocated just after this one:
struct _CrtMemBlockHeader *pBlockHeaderPrev;
char *szFileName; // File name
int nLine; // Line number
#if SCP_COMPILER_VERSION_MAJOR >= 19
// m!m - I am assuming here that the change of the block header got introduced in my version of VS
// If memory allocation seems off, check here
int nBlockUse; // Type of block
size_t nDataSize; // Size of user block
#else
size_t nDataSize; // Size of user block
int nBlockUse; // Type of block
#endif
long lRequest; // Allocation number
// Buffer just before (lower than) the user's memory:
unsigned char gap[4];
} _CrtMemBlockHeader;
_CrtMemBlockHeader* get_crt_header(void* ptr)
{
return reinterpret_cast<_CrtMemBlockHeader*>(ptr) - 1;
}
int allocation_hook(int allocType, void *userData, size_t size, int blockType,
long requestNumber, const unsigned char *filename, int lineNumber)
{
// Ignore CRT blocks
if (blockType == _CRT_BLOCK)
return 1;
// Don't record blocks allocated using the untracked_* versions
if (blockType == UNTRACKED_BLOCK)
return 1;
switch (allocType)
{
case _HOOK_ALLOC:
{
memory::register_malloc(size, reinterpret_cast<const char*>(filename), lineNumber);
break;
}
case _HOOK_FREE:
{
auto header = get_crt_header(userData);
memory::unregister_malloc(header->nDataSize, header->szFileName, header->nLine);
break;
}
case _HOOK_REALLOC:
{
if (userData == nullptr)
{
memory::register_malloc(size, reinterpret_cast<const char*>(filename), lineNumber);
}
else
{
auto header = get_crt_header(userData);
memory::unregister_malloc(header->nDataSize, header->szFileName, header->nLine);
memory::register_malloc(size, reinterpret_cast<const char*>(filename), lineNumber);
}
break;
}
default:
break;
}
return 1;
}
}
namespace memory
{
void debug_init()
{
_CrtSetAllocHook(allocation_hook);
}
void debug_exit()
{
_CrtDumpMemoryLeaks();
}
}
void *_vm_malloc(size_t size, const memory::quiet_alloc_t &, const char *filename, int line)
{
auto ptr = _malloc_dbg(size, _NORMAL_BLOCK, filename, line);
if (ptr == nullptr)
{
mprintf(("Malloc failed!!!!!!!!!!!!!!!!!!!\n"));
}
return ptr;
}
void _vm_free(void *ptr, const char*, int)
{
_free_dbg(ptr, _NORMAL_BLOCK);
}
void *_vm_realloc(void *ptr, size_t size, const memory::quiet_alloc_t &, const char *filename, int line)
{
auto ret_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK, filename, line);
if (ret_ptr == nullptr)
{
mprintf(("Malloc failed!!!!!!!!!!!!!!!!!!!\n"));
}
return ret_ptr;
}
void* malloc_untracked(size_t size)
{
return _malloc_dbg(size, UNTRACKED_BLOCK, nullptr, -1);
}
void free_untracked(void* ptr)
{
_free_dbg(ptr, UNTRACKED_BLOCK);
}
#endif
+289
View File
@@ -0,0 +1,289 @@
#include "globalincs/memory/memory.h"
#ifndef NDEBUG
#include "globalincs/memory/debug.h"
#endif
#include "globalincs/pstypes.h"
#include "cmdline/cmdline.h"
#include <unordered_map>
#include <mutex>
#include <algorithm>
#ifdef new
#undef new
#endif
namespace
{
// We need to use an allocator that uses std::malloc specifically so we don't cause infinite recursion
template<class T>
struct malloc_allocator
{
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T *pointer;
typedef const T *const_pointer;
typedef T &reference;
typedef const T &const_reference;
typedef T value_type;
template<class U>
struct rebind
{
typedef malloc_allocator<U> other;
};
malloc_allocator() SCP_NOEXCEPT
{ }
malloc_allocator(const malloc_allocator &) SCP_NOEXCEPT
{ }
template<class U>
malloc_allocator(const malloc_allocator<U> &) SCP_NOEXCEPT
{ }
~malloc_allocator() throw()
{ }
pointer address(reference x) const
{ return &x; }
const_pointer address(const_reference x) const
{ return &x; }
pointer allocate(size_type s, void const * = 0)
{
if (0 == s)
return NULL;
pointer temp = (pointer) malloc_untracked(s * sizeof(T));
if (temp == NULL)
throw std::bad_alloc();
return temp;
}
void deallocate(pointer p, size_type)
{
free_untracked(p);
}
size_type max_size() const throw()
{
return std::numeric_limits<size_t>::max() / sizeof(T);
}
void construct(pointer p, const T &val)
{
new((void *) p) T(val);
}
void destroy(pointer p)
{
p->~T();
}
};
struct MemoryInformation
{
const char *filename;
size_t memory;
};
struct string_hash
{
size_t operator()(const char *s) const
{
size_t hash = 0;
auto len = std::strlen(s);
for (size_t i = 0; i < len; ++i)
hash = 65599 * hash + s[i];
return hash ^ (hash >> 16);
}
};
struct string_equal
{
bool operator()(const char *s1, const char *s2) const
{
return std::strcmp(s1, s2) == 0;
}
};
bool meminfo_sort_compare(const MemoryInformation &arg1, const MemoryInformation &arg2)
{
return arg1.memory > arg2.memory;
}
typedef std::unordered_map<const char *, MemoryInformation,
string_hash, string_equal,
malloc_allocator<std::pair<const char *const, MemoryInformation>>> MemoryAllocationMap;
typedef std::vector<MemoryInformation, malloc_allocator<MemoryInformation>> MemoryAllocationVector;
MemoryAllocationMap *allocationMap = nullptr;
// Buffer for sorting
MemoryAllocationVector allocationVector;
size_t usedMemory = 0;
std::mutex reportLock;
void memory_uninit()
{
#ifndef NDEBUG
memory::debug_exit();
#endif
if (allocationMap != nullptr)
{
// Need to make sure we don't call the overridden operators
allocationMap->~MemoryAllocationMap();
free_untracked(allocationMap);
allocationMap = nullptr;
}
}
}
namespace memory
{
const quiet_alloc_t quiet_alloc;
void init()
{
#ifndef NDEBUG
memory::debug_init();
allocationMap = new(malloc_untracked(sizeof(*allocationMap))) MemoryAllocationMap();
#endif
std::atexit(memory_uninit);
}
size_t get_used_memory()
{
return usedMemory;
}
size_t sort_memory_blocks()
{
if (allocationMap == nullptr)
{
return 0;
}
allocationVector.clear();
allocationVector.reserve(allocationMap->size());
for (auto &kv : *allocationMap)
{
allocationVector.push_back(kv.second);
}
std::sort(allocationVector.begin(), allocationVector.end(), meminfo_sort_compare);
return allocationVector.size();
}
bool get_memory_block(size_t index, const char *&fileName, size_t &memory)
{
if (index >= allocationVector.size())
{
return false;
}
auto &entry = allocationVector[index];
fileName = entry.filename;
memory = entry.memory;
return true;
}
// Memory tracking functions
void register_malloc(size_t size, const char *filename, int)
{
// MSVC <= 2013 somehow allocates memory when locking a mutex
// MSVC >= 2015 should be fine, for earlier version this probably means
// that the values will be corrupted but at least they will be able to run...
#if !SCP_COMPILER_IS_MSVC || SCP_COMPILER_VERSION_MAJOR >= 19
std::lock_guard<std::mutex> guard(reportLock);
#endif
usedMemory += size;
if (filename == nullptr)
{
// Origin not known
filename = "<Unknown>";
}
if (Cmdline_show_mem_usage && allocationMap != nullptr)
{
auto foundIter = allocationMap->find(filename);
if (foundIter == allocationMap->end())
{
MemoryInformation newVal;
newVal.filename = filename;
newVal.memory = 0;
foundIter = allocationMap->insert(std::make_pair(filename, newVal)).first;
}
foundIter->second.memory += size;
}
}
void unregister_malloc(size_t size, const char *filename, int)
{
// MSVC <= 2013 somehow allocates memory when locking a mutex
// MSVC >= 2015 should be fine, for earlier version this probably means
// that the values will be corrupted but at least they will be able to run...
#if !SCP_COMPILER_IS_MSVC || SCP_COMPILER_VERSION_MAJOR >= 19
std::lock_guard<std::mutex> guard(reportLock);
#endif
usedMemory -= size;
if (filename == nullptr)
{
// Origin not known
filename = "<Unknown>";
}
if (Cmdline_show_mem_usage && allocationMap != nullptr)
{
auto foundIter = allocationMap->find(filename);
if (foundIter == allocationMap->end())
{
MemoryInformation newVal;
newVal.filename = filename;
newVal.memory = 0;
foundIter = allocationMap->insert(std::make_pair(filename, newVal)).first;
}
if (size > foundIter->second.memory)
{
// We freed more memory than allocated for this file
// This can happen if one file allocates memory and another deallocates it
foundIter->second.memory = 0;
}
else
{
foundIter->second.memory -= size;
}
}
}
void out_of_memory(const char *filename, int line)
{
mprintf(("Memory allocation failed!!!!!!!!!!!!!!!!!!!\n"));
Error(filename, line, "Out of memory. Try closing down other applications, increasing your\n"
"virtual memory size, or installing more physical RAM.\n");
}
}
+22
View File
@@ -0,0 +1,22 @@
#pragma once
#include <stddef.h>
namespace memory
{
void init();
size_t get_used_memory();
struct quiet_alloc_t { quiet_alloc_t(){} };
extern const quiet_alloc_t quiet_alloc;
void register_malloc(size_t size, const char *filename, int line);
void unregister_malloc(size_t size, const char *filename, int line);
size_t sort_memory_blocks();
bool get_memory_block(size_t index, const char*& fileName, size_t& usedMemory);
void out_of_memory(const char* filename, int line);
}
+63
View File
@@ -0,0 +1,63 @@
#include "globalincs/pstypes.h"
// Compile new version of new and delete which replace the ones provided by the runtime
// This will make sure that everyone uses our operators
#ifdef new
#undef new
#endif
// throw
void * operator new (size_t size)
{
void *p = vm_malloc(size, memory::quiet_alloc);
if ( !p ) {
throw std::bad_alloc();
}
return p;
}
void operator delete (void *p) SCP_NOEXCEPT
{
vm_free(p);
}
void * operator new [] (size_t size)
{
void *p = vm_malloc(size, memory::quiet_alloc);
if ( !p ) {
throw std::bad_alloc();
}
return p;
}
void operator delete [] (void *p) SCP_NOEXCEPT
{
vm_free(p);
}
// no-throw
void * operator new (size_t size, const std::nothrow_t&) SCP_NOEXCEPT
{
return vm_malloc(size, memory::quiet_alloc);
}
void operator delete (void *p, const std::nothrow_t&) SCP_NOEXCEPT
{
vm_free(p);
}
void * operator new [] (size_t size, const std::nothrow_t&) SCP_NOEXCEPT
{
return vm_malloc(size, memory::quiet_alloc);
}
void operator delete [] (void *p, const std::nothrow_t&) SCP_NOEXCEPT
{
vm_free(p);
}
+65
View File
@@ -0,0 +1,65 @@
#pragma once
#ifndef NDEBUG
#error Release memory management header included in debug build!
#endif
#include <cstdlib>
#include "globalincs/pstypes.h"
#include "globalincs/memory/memory.h"
inline void *vm_malloc(size_t size, const memory::quiet_alloc_t &)
{ return std::malloc(size); }
inline void *vm_malloc(size_t size)
{
auto ptr = vm_malloc(size, memory::quiet_alloc);
if (ptr == NULL)
{
memory::out_of_memory("Unknown", -1);
}
return ptr;
}
inline void vm_free(void *ptr)
{ std::free(ptr); }
inline void *vm_realloc(void *ptr, size_t size, const memory::quiet_alloc_t &)
{ return std::realloc(ptr, size); }
inline void *vm_realloc(void *ptr, size_t size)
{
auto ret_ptr = vm_realloc(ptr, size, memory::quiet_alloc);
if (ret_ptr == NULL)
{
memory::out_of_memory("Unknown", -1);
}
return ret_ptr;
}
inline void* malloc_location(size_t size, const char*, int)
{
return vm_malloc(size);
}
inline void free_location(void* ptr, const char*, int)
{
vm_free(ptr);
}
// untracked versions DON'T USE IN NORMAL CODE!!
inline void *malloc_untracked(size_t size)
{
return std::malloc(size);
}
inline void free_untracked(void *ptr)
{
std::free(ptr);
}
+55
View File
@@ -0,0 +1,55 @@
#pragma once
#include <cstring>
#include "globalincs/pstypes.h"
#ifndef NDEBUG
inline char *_vm_strdup(const char *ptr, const char *filename, int line)
#else
inline char *vm_strdup(const char *ptr)
#endif
{
size_t len = std::strlen(ptr);
#ifndef NDEBUG
char *dst = (char *) _vm_malloc(len + 1, filename, line);
#else
char *dst = (char *) vm_malloc(len + 1);
#endif
if (!dst)
return NULL;
std::strcpy(dst, ptr);
return dst;
}
#ifndef NDEBUG
inline char *_vm_strndup(const char *ptr, size_t size, const char *filename, int line)
#else
inline char *vm_strndup(const char *ptr, size_t size)
#endif
{
#ifndef NDEBUG
char *dst = (char *) _vm_malloc(size + 1, filename, line);
#else
char *dst = (char *) vm_malloc(size + 1);
#endif
if (!dst)
return NULL;
std::strncpy(dst, ptr, size);
// make sure it has a NULL terminiator
dst[size] = '\0';
return dst;
}
#ifndef NDEBUG
#define vm_strdup(ptr) _vm_strdup((ptr),__FILE__,__LINE__)
#define vm_strndup(ptr, size) _vm_strndup((ptr),(size),__FILE__,__LINE__)
#endif
-305
View File
@@ -1,305 +0,0 @@
// ISO C9x compliant inttypes.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_INTTYPES_H_ // [
#define _MSC_INTTYPES_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include "stdint.h"
// 7.8 Format conversion of integer types
typedef struct {
intmax_t quot;
intmax_t rem;
} imaxdiv_t;
// 7.8.1 Macros for format specifiers
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
// The fprintf macros for signed integers are:
#define PRId8 "d"
#define PRIi8 "i"
#define PRIdLEAST8 "d"
#define PRIiLEAST8 "i"
#define PRIdFAST8 "d"
#define PRIiFAST8 "i"
#define PRId16 "hd"
#define PRIi16 "hi"
#define PRIdLEAST16 "hd"
#define PRIiLEAST16 "hi"
#define PRIdFAST16 "hd"
#define PRIiFAST16 "hi"
#define PRId32 "I32d"
#define PRIi32 "I32i"
#define PRIdLEAST32 "I32d"
#define PRIiLEAST32 "I32i"
#define PRIdFAST32 "I32d"
#define PRIiFAST32 "I32i"
#define PRId64 "I64d"
#define PRIi64 "I64i"
#define PRIdLEAST64 "I64d"
#define PRIiLEAST64 "I64i"
#define PRIdFAST64 "I64d"
#define PRIiFAST64 "I64i"
#define PRIdMAX "I64d"
#define PRIiMAX "I64i"
#define PRIdPTR "Id"
#define PRIiPTR "Ii"
// The fprintf macros for unsigned integers are:
#define PRIo8 "o"
#define PRIu8 "u"
#define PRIx8 "x"
#define PRIX8 "X"
#define PRIoLEAST8 "o"
#define PRIuLEAST8 "u"
#define PRIxLEAST8 "x"
#define PRIXLEAST8 "X"
#define PRIoFAST8 "o"
#define PRIuFAST8 "u"
#define PRIxFAST8 "x"
#define PRIXFAST8 "X"
#define PRIo16 "ho"
#define PRIu16 "hu"
#define PRIx16 "hx"
#define PRIX16 "hX"
#define PRIoLEAST16 "ho"
#define PRIuLEAST16 "hu"
#define PRIxLEAST16 "hx"
#define PRIXLEAST16 "hX"
#define PRIoFAST16 "ho"
#define PRIuFAST16 "hu"
#define PRIxFAST16 "hx"
#define PRIXFAST16 "hX"
#define PRIo32 "I32o"
#define PRIu32 "I32u"
#define PRIx32 "I32x"
#define PRIX32 "I32X"
#define PRIoLEAST32 "I32o"
#define PRIuLEAST32 "I32u"
#define PRIxLEAST32 "I32x"
#define PRIXLEAST32 "I32X"
#define PRIoFAST32 "I32o"
#define PRIuFAST32 "I32u"
#define PRIxFAST32 "I32x"
#define PRIXFAST32 "I32X"
#define PRIo64 "I64o"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#define PRIX64 "I64X"
#define PRIoLEAST64 "I64o"
#define PRIuLEAST64 "I64u"
#define PRIxLEAST64 "I64x"
#define PRIXLEAST64 "I64X"
#define PRIoFAST64 "I64o"
#define PRIuFAST64 "I64u"
#define PRIxFAST64 "I64x"
#define PRIXFAST64 "I64X"
#define PRIoMAX "I64o"
#define PRIuMAX "I64u"
#define PRIxMAX "I64x"
#define PRIXMAX "I64X"
#define PRIoPTR "Io"
#define PRIuPTR "Iu"
#define PRIxPTR "Ix"
#define PRIXPTR "IX"
// The fscanf macros for signed integers are:
#define SCNd8 "d"
#define SCNi8 "i"
#define SCNdLEAST8 "d"
#define SCNiLEAST8 "i"
#define SCNdFAST8 "d"
#define SCNiFAST8 "i"
#define SCNd16 "hd"
#define SCNi16 "hi"
#define SCNdLEAST16 "hd"
#define SCNiLEAST16 "hi"
#define SCNdFAST16 "hd"
#define SCNiFAST16 "hi"
#define SCNd32 "ld"
#define SCNi32 "li"
#define SCNdLEAST32 "ld"
#define SCNiLEAST32 "li"
#define SCNdFAST32 "ld"
#define SCNiFAST32 "li"
#define SCNd64 "I64d"
#define SCNi64 "I64i"
#define SCNdLEAST64 "I64d"
#define SCNiLEAST64 "I64i"
#define SCNdFAST64 "I64d"
#define SCNiFAST64 "I64i"
#define SCNdMAX "I64d"
#define SCNiMAX "I64i"
#ifdef _WIN64 // [
# define SCNdPTR "I64d"
# define SCNiPTR "I64i"
#else // _WIN64 ][
# define SCNdPTR "ld"
# define SCNiPTR "li"
#endif // _WIN64 ]
// The fscanf macros for unsigned integers are:
#define SCNo8 "o"
#define SCNu8 "u"
#define SCNx8 "x"
#define SCNX8 "X"
#define SCNoLEAST8 "o"
#define SCNuLEAST8 "u"
#define SCNxLEAST8 "x"
#define SCNXLEAST8 "X"
#define SCNoFAST8 "o"
#define SCNuFAST8 "u"
#define SCNxFAST8 "x"
#define SCNXFAST8 "X"
#define SCNo16 "ho"
#define SCNu16 "hu"
#define SCNx16 "hx"
#define SCNX16 "hX"
#define SCNoLEAST16 "ho"
#define SCNuLEAST16 "hu"
#define SCNxLEAST16 "hx"
#define SCNXLEAST16 "hX"
#define SCNoFAST16 "ho"
#define SCNuFAST16 "hu"
#define SCNxFAST16 "hx"
#define SCNXFAST16 "hX"
#define SCNo32 "lo"
#define SCNu32 "lu"
#define SCNx32 "lx"
#define SCNX32 "lX"
#define SCNoLEAST32 "lo"
#define SCNuLEAST32 "lu"
#define SCNxLEAST32 "lx"
#define SCNXLEAST32 "lX"
#define SCNoFAST32 "lo"
#define SCNuFAST32 "lu"
#define SCNxFAST32 "lx"
#define SCNXFAST32 "lX"
#define SCNo64 "I64o"
#define SCNu64 "I64u"
#define SCNx64 "I64x"
#define SCNX64 "I64X"
#define SCNoLEAST64 "I64o"
#define SCNuLEAST64 "I64u"
#define SCNxLEAST64 "I64x"
#define SCNXLEAST64 "I64X"
#define SCNoFAST64 "I64o"
#define SCNuFAST64 "I64u"
#define SCNxFAST64 "I64x"
#define SCNXFAST64 "I64X"
#define SCNoMAX "I64o"
#define SCNuMAX "I64u"
#define SCNxMAX "I64x"
#define SCNXMAX "I64X"
#ifdef _WIN64 // [
# define SCNoPTR "I64o"
# define SCNuPTR "I64u"
# define SCNxPTR "I64x"
# define SCNXPTR "I64X"
#else // _WIN64 ][
# define SCNoPTR "lo"
# define SCNuPTR "lu"
# define SCNxPTR "lx"
# define SCNXPTR "lX"
#endif // _WIN64 ]
#endif // __STDC_FORMAT_MACROS ]
// 7.8.2 Functions for greatest-width integer types
// 7.8.2.1 The imaxabs function
#define imaxabs _abs64
// 7.8.2.2 The imaxdiv function
// This is modified version of div() function from Microsoft's div.c found
// in %MSVC.NET%\crt\src\div.c
#ifdef STATIC_IMAXDIV // [
static
#else // STATIC_IMAXDIV ][
_inline
#endif // STATIC_IMAXDIV ]
imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
{
imaxdiv_t result;
result.quot = numer / denom;
result.rem = numer % denom;
if (numer < 0 && result.rem > 0) {
// did division wrong; must fix up
++result.quot;
result.rem -= denom;
}
return result;
}
// 7.8.2.3 The strtoimax and strtoumax functions
#define strtoimax _strtoi64
#define strtoumax _strtoui64
// 7.8.2.4 The wcstoimax and wcstoumax functions
#define wcstoimax _wcstoi64
#define wcstoumax _wcstoui64
#endif // _MSC_INTTYPES_H_ ]
-247
View File
@@ -1,247 +0,0 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006-2008 Alexander Chemeris
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif // _MSC_VER ]
#ifndef _MSC_STDINT_H_ // [
#define _MSC_STDINT_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include <limits.h>
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
// or compiler give many errors like this:
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#ifdef __cplusplus
extern "C++" {
#endif
# include <wchar.h>
#ifdef __cplusplus
}
#endif
// Define _W64 macros to mark types changing their size, like intptr_t.
#ifndef _W64
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
# define _W64 __w64
# else
# define _W64
# endif
#endif
// 7.18.1 Integer types
// 7.18.1.1 Exact-width integer types
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
// realize that, e.g. char has the same size as __int8
// so we give up on __intX for them.
#if (_MSC_VER < 1300)
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#else
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#endif
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
// 7.18.1.2 Minimum-width integer types
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
// 7.18.1.3 Fastest minimum-width integer types
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
// 7.18.1.4 Integer types capable of holding object pointers
#ifdef _WIN64 // [
typedef signed __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
#else // _WIN64 ][
typedef _W64 signed int intptr_t;
typedef _W64 unsigned int uintptr_t;
#endif // _WIN64 ]
// 7.18.1.5 Greatest-width integer types
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
// 7.18.2 Limits of specified-width integer types
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
// 7.18.2.1 Limits of exact-width integer types
#define INT8_MIN ((int8_t)_I8_MIN)
#define INT8_MAX _I8_MAX
#define INT16_MIN ((int16_t)_I16_MIN)
#define INT16_MAX _I16_MAX
#define INT32_MIN ((int32_t)_I32_MIN)
#define INT32_MAX _I32_MAX
#define INT64_MIN ((int64_t)_I64_MIN)
#define INT64_MAX _I64_MAX
#define UINT8_MAX _UI8_MAX
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define UINT64_MAX _UI64_MAX
// 7.18.2.2 Limits of minimum-width integer types
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MIN INT64_MIN
#define INT_LEAST64_MAX INT64_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
// 7.18.2.3 Limits of fastest minimum-width integer types
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MIN INT64_MIN
#define INT_FAST64_MAX INT64_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX
// 7.18.2.4 Limits of integer types capable of holding object pointers
#ifdef _WIN64 // [
# define INTPTR_MIN INT64_MIN
# define INTPTR_MAX INT64_MAX
# define UINTPTR_MAX UINT64_MAX
#else // _WIN64 ][
# define INTPTR_MIN INT32_MIN
# define INTPTR_MAX INT32_MAX
# define UINTPTR_MAX UINT32_MAX
#endif // _WIN64 ]
// 7.18.2.5 Limits of greatest-width integer types
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
// 7.18.3 Limits of other integer types
#ifdef _WIN64 // [
# define PTRDIFF_MIN _I64_MIN
# define PTRDIFF_MAX _I64_MAX
#else // _WIN64 ][
# define PTRDIFF_MIN _I32_MIN
# define PTRDIFF_MAX _I32_MAX
#endif // _WIN64 ]
#define SIG_ATOMIC_MIN INT_MIN
#define SIG_ATOMIC_MAX INT_MAX
#ifndef SIZE_MAX // [
# ifdef _WIN64 // [
# define SIZE_MAX _UI64_MAX
# else // _WIN64 ][
# define SIZE_MAX _UI32_MAX
# endif // _WIN64 ]
#endif // SIZE_MAX ]
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
#ifndef WCHAR_MIN // [
# define WCHAR_MIN 0
#endif // WCHAR_MIN ]
#ifndef WCHAR_MAX // [
# define WCHAR_MAX _UI16_MAX
#endif // WCHAR_MAX ]
#define WINT_MIN 0
#define WINT_MAX _UI16_MAX
#endif // __STDC_LIMIT_MACROS ]
// 7.18.4 Limits of other integer types
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
// 7.18.4.1 Macros for minimum-width integer constants
#define INT8_C(val) val##i8
#define INT16_C(val) val##i16
#define INT32_C(val) val##i32
#define INT64_C(val) val##i64
#define UINT8_C(val) val##ui8
#define UINT16_C(val) val##ui16
#define UINT32_C(val) val##ui32
#define UINT64_C(val) val##ui64
// 7.18.4.2 Macros for greatest-width integer constants
#define INTMAX_C INT64_C
#define UINTMAX_C UINT64_C
#endif // __STDC_CONSTANT_MACROS ]
#endif // _MSC_STDINT_H_ ]
+28 -69
View File
@@ -17,6 +17,8 @@
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <algorithm>
#include <cstdint>
#include "globalincs/toolchain.h"
#if defined( __x86_64__ ) || defined( _WIN64 )
@@ -36,7 +38,7 @@
#define MAX_PLAYERS 12
#define USE_INLINE_ASM 1 // Define this to use inline assembly
#define STRUCT_CMP(a, b) memcmp((void *)&a, (void *)&b, sizeof(a))
#define STRUCT_CMP(a, b) memcmp((void *) &a, (void *) &b, sizeof(a))
#ifdef LOCAL
#undef LOCAL
@@ -221,6 +223,14 @@ typedef struct flag_def_list {
ubyte var;
} def_list;
template<class T>
struct flag_def_list_new {
const char* name; // The parseable representation of this flag
T def; // The flag definition for this flag
bool in_use; // Whether or not this flag is currently in use or obsolete
bool is_special; // Whether this flag requires special processing. See parse_string_flag_list<T, T> for details
};
// weapon count list (mainly for pilot files)
typedef struct wep_t {
int index;
@@ -316,6 +326,7 @@ const float RAND_MAX_1f = (1.0f / RAND_MAX);
extern int Fred_running; // Is Fred running, or FreeSpace?
const size_t INVALID_SIZE = static_cast<size_t>(-1);
//======================================================================================
//======================================================================================
@@ -340,11 +351,13 @@ extern int Fred_running; // Is Fred running, or FreeSpace?
#undef USE_INLINE_ASM
#define INTEL_INT(x) SDL_Swap32(x)
#define INTEL_LONG(x) SDL_Swap64(x)
#define INTEL_SHORT(x) SDL_Swap16(x)
#define INTEL_FLOAT(x) SDL_SwapFloat((*x))
#else // Little Endian -
#define INTEL_INT(x) x
#define INTEL_LONG(x) x
#define INTEL_SHORT(x) x
#define INTEL_FLOAT(x) (*x)
#endif // BYTE_ORDER
@@ -472,71 +485,6 @@ template <class T> void CAP( T& v, T mn, T mx )
// Memory management functions
//=========================================================
// Returns 0 if not enough RAM.
int vm_init(int min_heap_size);
// Frees all RAM.
void vm_free_all();
#ifndef NDEBUG
// Debug versions
// Allocates some RAM.
void *_vm_malloc( int size, char *filename = NULL, int line = -1, int quiet = 0 );
// allocates some RAM for a string
char *_vm_strdup( const char *ptr, char *filename, int line );
// allocates some RAM for a string of a certain length
char *_vm_strndup( const char *ptr, int size, char *filename, int line );
// Frees some RAM.
void _vm_free( void *ptr, char *filename = NULL, int line= -1 );
// reallocates some RAM
void *_vm_realloc( void *ptr, int size, char *filename = NULL, int line= -1, int quiet = 0 );
// Easy to use macros
#define vm_malloc(size) _vm_malloc((size),__FILE__,__LINE__,0)
#define vm_free(ptr) _vm_free((ptr),__FILE__,__LINE__)
#define vm_strdup(ptr) _vm_strdup((ptr),__FILE__,__LINE__)
#define vm_strndup(ptr, size) _vm_strndup((ptr),(size),__FILE__,__LINE__)
#define vm_realloc(ptr, size) _vm_realloc((ptr),(size),__FILE__,__LINE__,0)
// quiet macro versions which don't report errors
#define vm_malloc_q(size) _vm_malloc((size),__FILE__,__LINE__,1)
#define vm_realloc_q(ptr, size) _vm_realloc((ptr),(size),__FILE__,__LINE__,1)
#else
// Release versions
// Allocates some RAM.
void *_vm_malloc( int size, int quiet = 0 );
// allocates some RAM for a string
char *_vm_strdup( const char *ptr );
// allocates some RAM for a strings of a certain length
char *_vm_strndup( const char *ptr, int size );
// Frees some RAM.
void _vm_free( void *ptr );
// reallocates some RAM
void *_vm_realloc( void *ptr, int size, int quiet = 0 );
// Easy to use macros
#define vm_malloc(size) _vm_malloc((size),0)
#define vm_free(ptr) _vm_free(ptr)
#define vm_strdup(ptr) _vm_strdup(ptr)
#define vm_strndup(ptr, size) _vm_strndup((ptr),(size))
#define vm_realloc(ptr, size) _vm_realloc((ptr),(size),0)
// quiet macro versions which don't report errors
#define vm_malloc_q(size) _vm_malloc((size),1)
#define vm_realloc_q(ptr, size) _vm_realloc((ptr),(size),1)
#endif
#include "globalincs/fsmemory.h"
//=========================================================
@@ -560,13 +508,13 @@ class camid
{
private:
int sig;
uint idx;
size_t idx;
public:
camid();
camid(int n_idx, int n_sig);
camid(size_t n_idx, int n_sig);
class camera *getCamera();
uint getIndex();
size_t getIndex();
int getSignature();
bool isValid();
};
@@ -582,6 +530,7 @@ SCP_string dump_stacktrace();
// ref: http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html
#ifndef NDEBUG
#if SCP_COMPILER_CXX_STATIC_ASSERT && SCP_COMPILER_CXX_AUTO_TYPE
#ifndef USING_THIRD_PARTY_LIBS
// feature support seems to be: gcc clang msvc
// auto 4.4 2.9 2010
// std::is_trivial 4.5 ? 2012 (2010 only duplicates std::is_pod)
@@ -593,6 +542,9 @@ SCP_string dump_stacktrace();
const auto ptr_memset = std::memset;
#define memset memset_if_trivial_else_error
// Put into std to be compatible with code that uses std::mem*
namespace std
{
template<typename T>
void *memset_if_trivial_else_error(T *memset_data, int ch, size_t count)
{
@@ -663,6 +615,13 @@ SCP_string dump_stacktrace();
static_assert(std::is_trivial<U>::value, "memmove on non-trivial object U");
return ptr_memmove(memmove_dest, memmove_src, count);
}
}
// Put into global namespace
using std::memcpy_if_trivial_else_error;
using std::memmove_if_trivial_else_error;
using std::memset_if_trivial_else_error;
#endif // USING_THIRD_PARTY_LIBS
#endif // HAVE_CXX11
#endif // NDEBUG
-3
View File
@@ -265,9 +265,6 @@ public:
#define PROFILE(name, function) { profile_begin(name); function; profile_end(name); }
//====================================================================================
// Memory stuff from WinDebug.cpp
extern int TotalRam;
void windebug_memwatch_init();
#define MAX_LIGHTS 256
#define MAX_LIGHT_LEVELS 16
-520
View File
@@ -749,523 +749,3 @@ SCP_string dump_stacktrace()
return "No stacktrace available!";
#endif
}
//================= memory stuff
/*
char *format_mem( DWORD num )
{
if ( num < 1024 ) {
sprintf( tmp_mem, "%d bytes", num );
} else if ( num < 1024*1024 ) {
sprintf( tmp_mem, "%.3f KB", (float)num/1024.0f );
} else {
sprintf( tmp_mem, "%.3f MB", (float)(num/1024)/(1024.0f) );
}
return tmp_mem;
}
*/
/*
void getmem()
{
DWORD retval;
MEMORY_BASIC_INFORMATION mbi ;
HINSTANCE hInstance;
MEMORYSTATUS ms;
ms.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus(&ms);
printf( "Percent of memory in use: %d%%\n", ms.dwMemoryLoad );
printf( "Bytes of physical memory: %s\n", format_mem(ms.dwTotalPhys) );
printf( "Free physical memory bytes: %s\n", format_mem(ms.dwAvailPhys) ); //
printf( "Bytes of paging file: %s\n", format_mem(ms.dwTotalPageFile) ); // bytes of paging file
printf( "Free bytes of paging file: %s\n", format_mem(ms.dwAvailPageFile) ); // free bytes of paging file
printf( "User bytes of address space: %s\n", format_mem(ms.dwTotalVirtual) ); //
printf( "Free user bytes: %s\n", format_mem(ms.dwAvailVirtual) ); // free user bytes
// Get the instance handle of the module where caller belongs to
retval = VirtualQuery( getmem, &mbi, sizeof( mbi ) ) ;
// The instance handle is equal to the allocation base in Win32
hInstance = (HINSTANCE)mbi.AllocationBase ;
if( ( retval == sizeof( mbi ) ) && hInstance ) {
printf( "Virtual Query succeeded...\n" );
} else {
printf( "Virtual Query failed...\n" );
}
}
*/
#ifndef NDEBUG
int TotalRam = 0;
#define nNoMansLandSize 4
typedef struct _CrtMemBlockHeader
{
struct _CrtMemBlockHeader * pBlockHeaderNext;
struct _CrtMemBlockHeader * pBlockHeaderPrev;
char * szFileName;
int nLine;
size_t nDataSize;
int nBlockUse;
long lRequest;
unsigned char gap[nNoMansLandSize];
/* followed by:
* unsigned char data[nDataSize];
* unsigned char anotherGap[nNoMansLandSize];
*/
} _CrtMemBlockHeader;
#define pHdr(pbData) (((_CrtMemBlockHeader *)pbData)-1)
// this block of code is never referenced...
#if 0
int __cdecl MyAllocHook(
int nAllocType,
void * pvData,
size_t nSize,
int nBlockUse,
long lRequest,
const char * szFileName,
int nLine
)
{
// char *operation[] = { "", "allocating", "re-allocating", "freeing" };
// char *blockType[] = { "Free", "Normal", "CRT", "Ignore", "Client" };
if ( nBlockUse == _CRT_BLOCK ) // Ignore internal C runtime library allocations
return( TRUE );
_ASSERT( ( nAllocType > 0 ) && ( nAllocType < 4 ) );
_ASSERT( ( nBlockUse >= 0 ) && ( nBlockUse < 5 ) );
if ( nAllocType == 3 ) {
_CrtMemBlockHeader *phd = pHdr(pvData);
nSize = phd->nDataSize;
}
// mprintf(( "Total RAM = %d\n", TotalRam ));
mprintf(( "Memory operation in %s, line %d: %s a %d-byte '%s' block (# %ld)\n",
szFileName, nLine, operation[nAllocType], nSize,
blockType[nBlockUse], lRequest ));
if ( pvData != NULL )
mprintf(( " at %X", pvData ));
mprintf(("\n" ));
return( TRUE ); // Allow the memory operation to proceed
}
#endif // #if 0
void windebug_memwatch_init()
{
//_CrtSetAllocHook(MyAllocHook);
TotalRam = 0;
}
#endif
int Watch_malloc = 0;
DCF_BOOL(watch_malloc, Watch_malloc );
// Returns 0 if not enough RAM.
int vm_init(int min_heap_size)
{
#ifndef NDEBUG
TotalRam = 0;
#endif
return 1;
}
#ifdef _DEBUG
#ifdef _REPORT_MEM_LEAKS
const int MAX_MEM_POINTERS = 50000;
typedef struct
{
char filename[33];
int size;
int line;
void *ptr;
} MemPtrInfo;
MemPtrInfo mem_ptr_list[MAX_MEM_POINTERS];
#endif
const int MAX_MEM_MODULES = 600;
typedef struct
{
char filename[33];
int size;
int magic_num1;
int magic_num2;
bool in_use;
} MemBlockInfo;
MemBlockInfo mem_block_list[MAX_MEM_MODULES];
int memblockinfo_sort_compare( const void *arg1, const void *arg2 )
{
MemBlockInfo *mbi1 = (MemBlockInfo *) arg1;
MemBlockInfo *mbi2 = (MemBlockInfo *) arg2;
if (mbi1->size > mbi2->size)
return -1;
if (mbi1->size < mbi2->size)
return 1;
return 0;
}
void memblockinfo_sort()
{
insertion_sort(mem_block_list, MAX_MEM_MODULES, sizeof(MemBlockInfo), memblockinfo_sort_compare );
}
void memblockinfo_sort_get_entry(int index, char *filename, int *size)
{
Assert(index < MAX_MEM_MODULES);
strcpy(filename, mem_block_list[index].filename);
*size = mem_block_list[index].size;
}
static bool first_time = true;
void register_malloc( int size, char *filename, int line, void *ptr)
{
if(first_time == true)
{
ZeroMemory(mem_block_list, MAX_MEM_MODULES * sizeof(MemBlockInfo) );
first_time = false;
// Get current flag
int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
// Turn on leak-checking bit
tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
// Set flag to the new value
_CrtSetDbgFlag( tmpFlag );
#ifdef _REPORT_MEM_LEAKS
ZeroMemory(mem_ptr_list, MAX_MEM_POINTERS * sizeof(MemPtrInfo));
#endif
}
char *temp = strrchr(filename, '\\');
if(temp)
filename = temp + 1;
// calculate magic numbers
int magic1, magic2, len = strlen(filename);
magic1 = magic2 = 0;
for(int c = 0; c < len; c++)
{
magic1 += filename[c];
if(c % 2)
magic2 += filename[c];
else
magic2 -= filename[c];
}
for(int i = 0; i < MAX_MEM_MODULES; i++)
{
// Found the first empty entry, fill it
if(mem_block_list[i].in_use == false)
{
strcpy_s(mem_block_list[i].filename, filename);
mem_block_list[i].size = size;
mem_block_list[i].magic_num1 = magic1;
mem_block_list[i].magic_num2 = magic2;
mem_block_list[i].in_use = true;
break;
}
// Found a matching entry, update it
if( mem_block_list[i].magic_num1 == magic1 &&
mem_block_list[i].magic_num2 == magic2 &&
stricmp(mem_block_list[i].filename, filename) == 0)
{
mem_block_list[i].size += size;
break;
}
}
// Now if system is compiled register it with the fuller system
#ifdef _REPORT_MEM_LEAKS
// Find empty slot
int count = 0;
while(mem_ptr_list[count].ptr != NULL)
{
count++;
// If you hit this just increase MAX_MEM_POINTERS
Assert(count < MAX_MEM_POINTERS);
}
mem_ptr_list[count].ptr = ptr;
mem_ptr_list[count].line = line;
mem_ptr_list[count].size = size;
strcpy_s(mem_ptr_list[count].filename, filename);
#endif
}
void memblockinfo_output_memleak()
{
if(!Cmdline_show_mem_usage) return;
if(TotalRam == 0)
return;
if(TotalRam < 0) {
_RPT1(_CRT_WARN, "TotalRam bad value!",TotalRam);
return;
}
_RPT1(_CRT_WARN, "malloc memory leak of %d\n",TotalRam);
// Now if system is compiled register it with the fuller system
#ifdef _REPORT_MEM_LEAKS
int total = 0;
// Find empty slot
for(int f = 0; f < MAX_MEM_POINTERS; f++)
{
if(mem_ptr_list[f].ptr)
{
_RPT3(_CRT_WARN, "Memory leaks: (%s line %d) of %d bytes\n", mem_ptr_list[f].filename, mem_ptr_list[f].line, mem_ptr_list[f].size);
total += mem_ptr_list[f].size;
}
}
Assert(TotalRam == total);
#else
for(int i = 0; i < MAX_MEM_MODULES; i++)
{
// Found the first empty entry, fill it
if(mem_block_list[i].size > 0)
{
// Oh... bad code... making assumsions...
_RPT2(_CRT_WARN, "Possible memory leaks: %s %d\n", mem_block_list[i].filename, mem_block_list[i].size);
}
}
#endif
}
void unregister_malloc(char *filename, int size, void *ptr)
{
// calculate magic numbers
int magic1, magic2, len;
char *temp = strrchr(filename, '\\');
if(temp)
filename = temp + 1;
len = strlen(filename);
magic1 = magic2 = 0;
for(int c = 0; c < len; c++)
{
magic1 += filename[c];
if(c % 2)
magic2 += filename[c];
else
magic2 -= filename[c];
}
// Now if system is compiled register it with the fuller system
#ifdef _REPORT_MEM_LEAKS
// Find empty slot
for(int f = 0; f < MAX_MEM_POINTERS; f++)
{
if(mem_ptr_list[f].ptr == ptr) {
mem_ptr_list[f].ptr = NULL;
break;
}
}
#endif
for(int i = 0; i < MAX_MEM_MODULES; i++)
{
// Found a matching entry, update it
if( mem_block_list[i].magic_num1 == magic1 &&
mem_block_list[i].magic_num2 == magic2 &&
stricmp(mem_block_list[i].filename, filename) == 0)
{
mem_block_list[i].size -= size;
return;
}
}
}
#endif
#ifndef NDEBUG
void *_vm_malloc( int size, char *filename, int line, int quiet )
#else
void *_vm_malloc( int size, int quiet )
#endif
{
void *ptr = NULL;
ptr = _malloc_dbg(size, _NORMAL_BLOCK, __FILE__, __LINE__ );
if (ptr == NULL)
{
mprintf(( "Malloc failed!!!!!!!!!!!!!!!!!!!\n" ));
if (quiet) {
return NULL;
}
Error(LOCATION, "Malloc Failed!\n");
}
#ifndef NDEBUG
TotalRam += size;
if(Cmdline_show_mem_usage)
register_malloc(size, filename, line, ptr);
#endif
return ptr;
}
#ifndef NDEBUG
char *_vm_strdup( const char *ptr, char *filename, int line )
#else
char *_vm_strdup( const char *ptr )
#endif
{
char *dst;
int len = strlen(ptr);
dst = (char *)vm_malloc( len+1 );
if (!dst)
return NULL;
strcpy_s( dst, len + 1, ptr );
return dst;
}
#ifndef NDEBUG
char *_vm_strndup( const char *ptr, int size, char *filename, int line )
#else
char *_vm_strndup( const char *ptr, int size )
#endif
{
char *dst;
dst = (char *)vm_malloc( size+1 );
if (!dst)
return NULL;
strncpy( dst, ptr, size );
// make sure it has a NULL terminiator
dst[size] = '\0';
return dst;
}
#ifndef NDEBUG
void _vm_free( void *ptr, char *filename, int line )
#else
void _vm_free( void *ptr )
#endif
{
if ( !ptr ) {
return;
}
#ifndef NDEBUG
_CrtMemBlockHeader *phd = pHdr(ptr);
int nSize = phd->nDataSize;
TotalRam -= nSize;
if(Cmdline_show_mem_usage)
unregister_malloc(filename, nSize, ptr);
#endif
_free_dbg(ptr,_NORMAL_BLOCK);
}
void vm_free_all()
{
}
#ifndef NDEBUG
void *_vm_realloc( void *ptr, int size, char *filename, int line, int quiet )
#else
void *_vm_realloc( void *ptr, int size, int quiet )
#endif
{
// if this is the first time it's used then we need to malloc it first
if ( ptr == NULL )
return vm_malloc(size);
void *ret_ptr = NULL;
#ifndef NDEBUG
// Unregistered the previous allocation
_CrtMemBlockHeader *phd = pHdr(ptr);
int nSize = phd->nDataSize;
TotalRam -= nSize;
if(Cmdline_show_mem_usage)
unregister_malloc(filename, nSize, ptr);
#endif
ret_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK, __FILE__, __LINE__ );
if (ret_ptr == NULL) {
mprintf(( "realloc failed!!!!!!!!!!!!!!!!!!!\n" ));
if (quiet && (size > 0) && (ptr != NULL)) {
// realloc doesn't touch the original ptr in the case of failure so we could still use it
return NULL;
}
Error(LOCATION, "Out of memory. Try closing down other applications, increasing your\n"
"virtual memory size, or installing more physical RAM.\n");
}
#ifndef NDEBUG
TotalRam += size;
// register this allocation
if(Cmdline_show_mem_usage)
register_malloc(size, filename, line, ret_ptr);
#endif
return ret_ptr;
}
+23 -17
View File
@@ -631,7 +631,7 @@ bool gr_unsize_screen_posf(float *x, float *y, float *w, float *h, int resize_mo
return true;
}
void gr_close()
void gr_close(os::GraphicsOperations* graphicsOps)
{
if ( !Gr_inited ) {
return;
@@ -639,9 +639,11 @@ void gr_close()
palette_flush();
font::close();
switch (gr_screen.mode) {
case GR_OPENGL:
gr_opengl_cleanup(true);
gr_opengl_cleanup(graphicsOps, true);
break;
case GR_STUB:
@@ -651,8 +653,6 @@ void gr_close()
Int3(); // Invalid graphics mode
}
gr_font_close();
Gr_inited = 0;
}
@@ -772,7 +772,7 @@ int gr_get_resolution_class(int width, int height)
}
}
static bool gr_init_sub(int mode, int width, int height, int depth, float center_aspect_ratio)
static bool gr_init_sub(os::GraphicsOperations* graphicsOps, int mode, int width, int height, int depth, float center_aspect_ratio)
{
int res = GR_1024;
bool rc = false;
@@ -874,7 +874,7 @@ static bool gr_init_sub(int mode, int width, int height, int depth, float center
switch (mode) {
case GR_OPENGL:
rc = gr_opengl_init();
rc = gr_opengl_init(graphicsOps);
break;
case GR_STUB:
rc = gr_stub_init();
@@ -890,21 +890,16 @@ static bool gr_init_sub(int mode, int width, int height, int depth, float center
return true;
}
bool gr_init(int d_mode, int d_width, int d_height, int d_depth)
bool gr_init(os::GraphicsOperations* graphicsOps, int d_mode, int d_width, int d_height, int d_depth)
{
int width = 1024, height = 768, depth = 32, mode = GR_OPENGL;
float center_aspect_ratio = -1.0f;
const char *ptr = NULL;
if ( !Gr_inited ) {
atexit(gr_close);
}
// If already inited, shutdown the previous graphics
if (Gr_inited) {
switch (gr_screen.mode) {
case GR_OPENGL:
gr_opengl_cleanup(false);
gr_opengl_cleanup(graphicsOps, false);
break;
case GR_STUB:
@@ -1068,7 +1063,7 @@ bool gr_init(int d_mode, int d_width, int d_height, int d_depth)
}
// now try to actually init everything...
if ( gr_init_sub(mode, width, height, depth, center_aspect_ratio) == false ) {
if ( gr_init_sub(graphicsOps, mode, width, height, depth, center_aspect_ratio) == false ) {
return false;
}
@@ -1409,10 +1404,10 @@ void gr_pline_special(SCP_vector<vec3d> *pts, int thickness,int resize_mode)
vec3d last_e1, last_e2;
vertex v[4];
vertex *verts[4] = {&v[0], &v[1], &v[2], &v[3]};
int saved_zbuffer_mode, idx;
int saved_zbuffer_mode;
int started_frame = 0;
int num_pts = pts->size();
size_t num_pts = pts->size();
// if we have less than 2 pts, bail
if(num_pts < 2) {
@@ -1436,7 +1431,7 @@ void gr_pline_special(SCP_vector<vec3d> *pts, int thickness,int resize_mode)
last_e1 = vmd_zero_vector;
last_e2 = vmd_zero_vector;
int j;
for(idx=0; idx<num_pts-1; idx++) {
for(size_t idx=0; idx<num_pts-1; idx++) {
// get the start and endpoints
s1 = pts->at(idx); // start 1 (on the line)
e1 = pts->at(idx+1); // end 1 (on the line)
@@ -2168,3 +2163,14 @@ uint gr_determine_model_shader_flags(
return shader_flags;
}
void gr_print_timestamp(int x, int y, int timestamp, int resize_mode)
{
char time[8];
// format the time information into strings
sprintf(time, "%.1d:%.2d:%.2d", (timestamp / 3600000) % 10, (timestamp / 60000) % 60, (timestamp / 1000) % 60);
time[7] = '\0';
gr_string(x, y, time, resize_mode);
}
+46 -31
View File
@@ -12,6 +12,7 @@
#ifndef _GRAPHICS_H
#define _GRAPHICS_H
#include <osapi/osapi.h>
#include "bmpman/bmpman.h"
#include "cfile/cfile.h"
#include "globalincs/pstypes.h"
@@ -196,7 +197,7 @@ public:
int flags;
int texture; // this is the texture the vertex buffer will use
int n_verts;
size_t n_verts;
size_t index_offset;
@@ -215,7 +216,7 @@ public:
}
}
void assign(int i, uint j)
void assign(size_t i, uint j)
{
const_cast<uint *>(index)[i] = j;
if (i_first > i_last)
@@ -234,7 +235,7 @@ public:
{
}
buffer_data(int n_vrts) :
explicit buffer_data(size_t n_vrts) :
flags(0), texture(-1), n_verts(n_vrts), index_offset(0),
i_first(1), i_last(0), index(NULL)
{
@@ -250,7 +251,7 @@ public:
{
if ( other.index ) {
index = new(std::nothrow) uint[other.n_verts];
for (size_t i=0; i < (size_t) other.n_verts; i++)
for (size_t i=0; i < other.n_verts; i++)
{
index[i] = other.index[i];
}
@@ -279,7 +280,7 @@ public:
if ( rhs.index && rhs.n_verts > 0 ) {
index = new(std::nothrow) uint[rhs.n_verts];
for (size_t i=0; i < (size_t) rhs.n_verts; i++)
for (size_t i=0; i < rhs.n_verts; i++)
{
index[i] = rhs.index[i];
}
@@ -312,7 +313,7 @@ class vertex_buffer
public:
int flags;
uint stride;
size_t stride;
size_t vertex_offset;
poly_list *model_list;
@@ -433,7 +434,7 @@ typedef struct screen {
void (*gf_aabitmap)(int x, int y, int resize_mode, bool mirror);
void (*gf_aabitmap_ex)(int x, int y, int w, int h, int sx, int sy, int resize_mode, bool mirror);
void (*gf_string)(int x, int y, const char * text,int resize_mode);
void(*gf_string)(float x, float y, const char * text, int resize_mode, int length);
// Draw a gradient line... x1,y1 is bright, x2,y2 is transparent.
void (*gf_gradient)(int x1, int y1, int x2, int y2, int resize_mode);
@@ -552,14 +553,14 @@ typedef struct screen {
bool (*gf_config_buffer)(const int buffer_id, vertex_buffer *vb, bool update_ibuffer_only);
void (*gf_destroy_buffer)(int);
void (*gf_set_buffer)(int);
void (*gf_render_buffer)(int, const vertex_buffer*, int, int);
void (*gf_render_buffer)(int, const vertex_buffer*, size_t, int);
void (*gf_update_buffer_object)(int handle, uint size, void* data);
void (*gf_update_transform_buffer)(void* data, uint size);
void (*gf_set_transform_buffer_offset)(int offset);
void (*gf_update_buffer_object)(int handle, size_t size, void* data);
void (*gf_update_transform_buffer)(void* data, size_t size);
void (*gf_set_transform_buffer_offset)(size_t offset);
int (*gf_create_stream_buffer)();
void (*gf_render_stream_buffer)(int buffer_handle, int offset, int n_verts, int flags);
void (*gf_render_stream_buffer)(int buffer_handle, size_t offset, size_t n_verts, int flags);
//the projection matrix; fov, aspect ratio, near, far
void (*gf_set_proj_matrix)(float, float, float, float);
@@ -655,12 +656,14 @@ typedef struct screen {
extern const char *Resolution_prefixes[GR_NUM_RESOLUTIONS];
extern bool gr_init(int d_mode = GR_DEFAULT, int d_width = GR_DEFAULT, int d_height = GR_DEFAULT, int d_depth = GR_DEFAULT);
extern bool gr_init(os::GraphicsOperations* graphicsOps, int d_mode = GR_DEFAULT,
int d_width = GR_DEFAULT, int d_height = GR_DEFAULT, int d_depth = GR_DEFAULT);
extern void gr_screen_resize(int width, int height);
extern int gr_get_resolution_class(int width, int height);
// Call this when your app ends.
extern void gr_close();
extern void gr_close(os::GraphicsOperations* graphicsOps);
extern screen gr_screen;
@@ -693,13 +696,13 @@ bool gr_resize_screen_posf(float *x, float *y, float *w = NULL, float *h = NULL,
// Does formatted printing. This calls gr_string after formatting,
// so if you don't need to format the string, then call gr_string
// directly.
extern void _cdecl gr_printf( int x, int y, const char * format, ... );
extern void gr_printf( int x, int y, const char * format, ... );
// same as gr_printf but positions text correctly in menus
extern void _cdecl gr_printf_menu( int x, int y, const char * format, ... );
extern void gr_printf_menu( int x, int y, const char * format, ... );
// same as gr_printf_menu but accounts for menu zooming
extern void _cdecl gr_printf_menu_zoomed( int x, int y, const char * format, ... );
extern void gr_printf_menu_zoomed( int x, int y, const char * format, ... );
// same as gr_printf but doesn't resize for non-standard resolutions
extern void _cdecl gr_printf_no_resize( int x, int y, const char * format, ... );
extern void gr_printf_no_resize( int x, int y, const char * format, ... );
// Returns the size of the string in pixels in w and h
extern void gr_get_string_size( int *w, int *h, const char * text, int len = 9999 );
@@ -709,11 +712,6 @@ extern int gr_get_font_height();
extern void gr_set_palette(const char *name, ubyte *palette, int restrict_to_128 = 0);
// These two functions use a Windows mono font. Only for use
// in the editor, please.
void gr_get_string_size_win(int *w, int *h, const char *text);
void gr_string_win(int x, int y, const char *s );
extern io::mouse::Cursor* Web_cursor;
// Called by OS when application gets/looses focus
@@ -758,9 +756,14 @@ void gr_shield_icon(coord2d coords[6], const int resize_mode = GR_RESIZE_FULL);
void gr_rect(int x, int y, int w, int h, int resize_mode = GR_RESIZE_FULL);
void gr_shade(int x, int y, int w, int h, int resize_mode = GR_RESIZE_FULL);
__inline void gr_string(int x, int y, const char* string, int resize_mode = GR_RESIZE_FULL)
__inline void gr_string(float x, float y, const char* string, int resize_mode = GR_RESIZE_FULL, int length = -1)
{
(*gr_screen.gf_string)(x,y,string,resize_mode);
(*gr_screen.gf_string)(x, y, string, resize_mode, length);
}
__inline void gr_string(int x, int y, const char* string, int resize_mode = GR_RESIZE_FULL, int length = -1)
{
gr_string(i2fl(x), i2fl(y), string, resize_mode, length);
}
__inline void gr_circle(int xc, int yc, int d, int resize_mode = GR_RESIZE_FULL)
@@ -866,7 +869,7 @@ __inline int gr_bm_set_render_target(int n, int face = -1)
#define gr_pack_buffer GR_CALL(*gr_screen.gf_pack_buffer)
#define gr_config_buffer GR_CALL(*gr_screen.gf_config_buffer)
#define gr_destroy_buffer GR_CALL(*gr_screen.gf_destroy_buffer)
__inline void gr_render_buffer(int start, const vertex_buffer *bufferp, int texi, int flags = TMAP_FLAG_TEXTURED)
__inline void gr_render_buffer(int start, const vertex_buffer *bufferp, size_t texi, int flags = TMAP_FLAG_TEXTURED)
{
(*gr_screen.gf_render_buffer)(start, bufferp, texi, flags);
}
@@ -1023,10 +1026,10 @@ struct vertex_format_data
};
vertex_format format_type;
uint stride;
size_t stride;
void *data_src;
vertex_format_data(vertex_format i_format_type, uint i_stride, void *i_data_src) :
vertex_format_data(vertex_format i_format_type, size_t i_stride, void *i_data_src) :
format_type(i_format_type), stride(i_stride), data_src(i_data_src) {}
};
@@ -1038,13 +1041,13 @@ class vertex_layout
public:
vertex_layout(): Vertex_mask(0) {}
uint get_num_vertex_components() { return Vertex_components.size(); }
size_t get_num_vertex_components() { return Vertex_components.size(); }
vertex_format_data* get_vertex_component(uint index) { return &Vertex_components[index]; }
vertex_format_data* get_vertex_component(size_t index) { return &Vertex_components[index]; }
bool resident_vertex_format(vertex_format_data::vertex_format format_type) { return Vertex_mask & (1 << format_type) ? true : false; }
void add_vertex_component(vertex_format_data::vertex_format format_type, uint stride, void* src)
void add_vertex_component(vertex_format_data::vertex_format format_type, size_t stride, void* src)
{
if ( resident_vertex_format(format_type) ) {
// we already have a vertex component of this format type
@@ -1058,4 +1061,16 @@ public:
/**
* @brief Prints the current time
*
* Draws the timestamp of the current #Missiontime in the format @c h:mm:ss at the specified coordinates
*
* @param x The x position where the timestamp should be draw
* @param y The y position where the timestamp should be draw
* @param timestamp The timespamp in milliseconds to be printed
* @param resize_mode The resize mode to use
*/
void gr_print_timestamp(int x, int y, int timestamp, int resize_mode);
#endif
-704
View File
@@ -1,704 +0,0 @@
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#ifdef _WIN32
#include <windows.h>
#include <windowsx.h>
#endif
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
#include "bmpman/bmpman.h"
#include "cfile/cfile.h"
#include "def_files/def_files.h"
#include "globalincs/systemvars.h"
#include "graphics/2d.h"
#include "graphics/font.h"
#include "io/key.h"
#include "localization/localize.h"
#include "palman/palman.h"
#include "parse/parselo.h"
#include "def_files/def_files.h"
int Num_fonts = 0;
font Fonts[MAX_FONTS];
font *Current_font = NULL;
/**
* Crops a string if required to force it to not exceed max_width pixels when printed.
* Does this by dropping characters at the end of the string and adding '...' to the end.
*
* @param str string to crop. Modifies this string directly
* @param max_str max characters allowed in str
* @param max_width number of pixels to limit string to (less than or equal to).
* @return Returns the width of the string as given by gr_get_string_size().
*/
int gr_force_fit_string(char *str, int max_str, int max_width)
{
int w;
gr_get_string_size(&w, NULL, str);
if (w > max_width) {
if ((int) strlen(str) > max_str - 3) {
Assert(max_str >= 3);
str[max_str - 3] = 0;
}
strcpy(str + strlen(str) - 1, "...");
gr_get_string_size(&w, NULL, str);
while (w > max_width) {
Assert(strlen(str) >= 4); // if this is hit, a bad max_width was passed in and the calling function needs fixing.
strcpy(str + strlen(str) - 4, "...");
gr_get_string_size(&w, NULL, str);
}
}
return w;
}
/**
* Takes the character BEFORE being offset into current font
* @return the letter code
*/
int get_char_width(ubyte c1,ubyte c2,int *width,int *spacing)
{
int i, letter;
Assert ( Current_font != NULL );
letter = c1-Current_font->first_ascii;
if (letter<0 || letter>=Current_font->num_chars) { //not in font, draw as space
*width=0;
*spacing = Current_font->w;
return -1;
}
*width = Current_font->char_data[letter].byte_width;
*spacing = Current_font->char_data[letter].spacing;
i = Current_font->char_data[letter].kerning_entry;
if ( i > -1) {
if (!(c2==0 || c2=='\n')) {
int letter2;
letter2 = c2-Current_font->first_ascii;
if ((letter2>=0) && (letter2<Current_font->num_chars) ) { //not in font, draw as space
font_kernpair *k = &Current_font->kern_data[i];
while( (k->c1 == (char)letter) && (k->c2<(char)letter2) && (i<Current_font->num_kern_pairs-1) ) {
i++;
k++;
}
if ( k->c2 == (char)letter2 ) {
*spacing += k->offset;
}
}
}
}
return letter;
}
// NOTE: this returns an unscaled size for non-standard resolutions
int get_centered_x(const char *s, bool scaled)
{
int w,w2,s2;
for (w=0;*s!=0 && *s!='\n';s++) {
get_char_width(s[0],s[1],&w2,&s2);
w += s2;
}
return (((scaled ? gr_screen.clip_width : gr_screen.clip_width_unscaled) - w) / 2);
}
/**
* Draws a character centered on x
*/
void gr_char_centered(int x, int y, char chr, ubyte sc1, int resize_mode)
{
char str[2];
int w;
if (chr == '1')
chr = (char)sc1;
str[0] = chr;
str[1] = 0;
gr_get_string_size(&w, NULL, str);
gr_string(x - w / 2, y, str, resize_mode);
}
void gr_print_timestamp(int x, int y, fix timestamp, int resize_mode)
{
char h[2], m[3], s[3];
int w, c, font_num;
ubyte sc;
int time = (int)f2fl(timestamp); // convert to seconds
// format the time information into strings
sprintf(h, "%.1d", (time / 3600));
sprintf(m, "%.2d", (time / 60) % 60);
sprintf(s, "%.2d", time % 60);
gr_get_string_size(&w, NULL, "0");
gr_get_string_size(&c, NULL, ":");
gr_string(x + w, y, ":", resize_mode);
gr_string(x + w * 3 + c, y, ":", resize_mode);
font_num = gr_get_current_fontnum();
if (font_num == -1) {
Warning(LOCATION, "Font not set - timestamps may not work correctly");
sc = 0;
} else {
sc = lcl_get_font_index(font_num);
}
if (sc == 0) {
sc = ubyte ('1'); // make do with non-mono-spaced 1
} else {
sc += 1;
}
x += w / 2;
gr_char_centered(x, y, h[0], sc, resize_mode);
x += w + c;
gr_char_centered(x, y, m[0], sc, resize_mode);
x += w;
gr_char_centered(x, y, m[1], sc, resize_mode);
x += w + c;
gr_char_centered(x, y, s[0], sc, resize_mode);
x += w;
gr_char_centered(x, y, s[1], sc, resize_mode);
}
int gr_get_font_height()
{
if (Current_font) {
return Current_font->h;
} else {
return 16;
}
}
void gr_get_string_size(int *w1, int *h1, const char *text, int len)
{
int longest_width;
int width,spacing;
int w, h;
if (!Current_font) {
if ( w1)
*w1 = 16;
if ( h1 )
*h1 = 16;
return;
}
w = 0;
h = 0;
longest_width = 0;
if (text != NULL ) {
h += Current_font->h;
while (*text && (len>0) ) {
// Process one or more
while ((*text == '\n') && (len>0) ) {
text++;
len--;
if ( *text ) {
h += Current_font->h;
}
w = 0;
}
if (*text == 0) {
break;
}
get_char_width(text[0], text[1], &width, &spacing);
w += spacing;
if (w > longest_width)
longest_width = w;
text++;
len--;
}
}
if ( h1 )
*h1 = h;
if ( w1 )
*w1 = longest_width;
}
MONITOR( FontChars )
#ifdef _WIN32
HFONT MyhFont = NULL;
HDC hDibDC = NULL;
void gr_string_win(int x, int y, const char *s)
{
int old_bitmap = gr_screen.current_bitmap;
gr_set_font(FONT1);
gr_string(x,y,s);
gr_screen.current_bitmap = old_bitmap;
}
void gr_get_string_size_win(int *w, int *h, const char *text)
{
const char *ptr;
SIZE size;
ptr = strchr(text, '\n');
if (MyhFont==NULL) {
if (w) *w = 0;
if (h) *h = 0;
return;
}
SelectObject( hDibDC, MyhFont );
if (!ptr) {
GetTextExtentPoint32( hDibDC, text, strlen(text), &size);
if (w) *w = size.cx;
if (h) *h = size.cy;
return;
}
GetTextExtentPoint32(hDibDC, text, ptr - text, &size);
gr_get_string_size_win(w, h, ptr+1);
if (w && (size.cx > *w) )
*w = size.cx;
if (h)
*h += size.cy;
}
#endif // ifdef _WIN32
char grx_printf_text[2048];
void _cdecl gr_printf( int x, int y, const char * format, ... )
{
va_list args;
if ( !Current_font ) return;
va_start(args, format);
vsnprintf(grx_printf_text, sizeof(grx_printf_text)-1, format, args);
va_end(args);
grx_printf_text[sizeof(grx_printf_text)-1] = '\0';
gr_string(x,y,grx_printf_text);
}
void _cdecl gr_printf_menu( int x, int y, const char * format, ... )
{
va_list args;
if ( !Current_font ) return;
va_start(args, format);
vsnprintf(grx_printf_text, sizeof(grx_printf_text)-1, format, args);
va_end(args);
grx_printf_text[sizeof(grx_printf_text)-1] = '\0';
gr_string(x,y,grx_printf_text,GR_RESIZE_MENU);
}
void _cdecl gr_printf_menu_zoomed( int x, int y, const char * format, ... )
{
va_list args;
if ( !Current_font ) return;
va_start(args, format);
vsnprintf(grx_printf_text, sizeof(grx_printf_text)-1, format, args);
va_end(args);
grx_printf_text[sizeof(grx_printf_text)-1] = '\0';
gr_string(x,y,grx_printf_text,GR_RESIZE_MENU_ZOOMED);
}
void _cdecl gr_printf_no_resize( int x, int y, const char * format, ... )
{
va_list args;
if ( !Current_font ) return;
va_start(args, format);
vsnprintf(grx_printf_text, sizeof(grx_printf_text)-1, format, args);
va_end(args);
grx_printf_text[sizeof(grx_printf_text)-1] = '\0';
gr_string(x,y,grx_printf_text,GR_RESIZE_NONE);
}
void gr_font_close()
{
font *fnt;
int i;
fnt = Fonts;
for (i=0; i<Num_fonts; i++) {
if (fnt->kern_data) {
vm_free(fnt->kern_data);
fnt->kern_data = NULL;
}
if (fnt->char_data) {
vm_free(fnt->char_data);
fnt->char_data = NULL;
}
if (fnt->pixel_data) {
vm_free(fnt->pixel_data);
fnt->pixel_data = NULL;
}
if (fnt->bm_data) {
vm_free(fnt->bm_data);
fnt->bm_data = NULL;
}
if (fnt->bm_u) {
vm_free(fnt->bm_u);
fnt->bm_u = NULL;
}
if (fnt->bm_v) {
vm_free(fnt->bm_v);
fnt->bm_v = NULL;
}
fnt++;
}
}
/**
* @return -1 if couldn't init font, otherwise returns the font id number.
*/
int gr_create_font(char * typeface)
{
CFILE *fp;
font *fnt;
int n, fontnum;
fnt = Fonts;
n = -1;
for (fontnum=0; fontnum<Num_fonts; fontnum++ ) {
if (fnt->id != 0 ) {
if ( !_strnicmp( fnt->filename, typeface, MAX_FILENAME_LEN ) ) {
return fontnum;
}
} else {
if ( n < 0 ) {
n = fontnum;
}
}
fnt++;
}
if ( fontnum == MAX_FONTS ) {
Warning( LOCATION, "Too many fonts!\nSee John, or change MAX_FONTS in Graphics\\Font.h\n" );
return -1;
}
if ( fontnum == Num_fonts ) {
Num_fonts++;
}
bool localize = true;
fp = cfopen( typeface, "rb", CFILE_NORMAL, CF_TYPE_ANY, localize );
if ( fp == NULL ) return -1;
strcpy_s( fnt->filename, typeface );
cfread( &fnt->id, 4, 1, fp );
cfread( &fnt->version, sizeof(int), 1, fp );
cfread( &fnt->num_chars, sizeof(int), 1, fp );
cfread( &fnt->first_ascii, sizeof(int), 1, fp );
cfread( &fnt->w, sizeof(int), 1, fp );
cfread( &fnt->h, sizeof(int), 1, fp );
cfread( &fnt->num_kern_pairs, sizeof(int), 1, fp );
cfread( &fnt->kern_data_size, sizeof(int), 1, fp );
cfread( &fnt->char_data_size, sizeof(int), 1, fp );
cfread( &fnt->pixel_data_size, sizeof(int), 1, fp );
fnt->id = INTEL_SHORT( fnt->id ); //-V570
fnt->version = INTEL_INT( fnt->version ); //-V570
fnt->num_chars = INTEL_INT( fnt->num_chars ); //-V570
fnt->first_ascii = INTEL_INT( fnt->first_ascii ); //-V570
fnt->w = INTEL_INT( fnt->w ); //-V570
fnt->h = INTEL_INT( fnt->h ); //-V570
fnt->num_kern_pairs = INTEL_INT( fnt->num_kern_pairs ); //-V570
fnt->kern_data_size = INTEL_INT( fnt->kern_data_size ); //-V570
fnt->char_data_size = INTEL_INT( fnt->char_data_size ); //-V570
fnt->pixel_data_size = INTEL_INT( fnt->pixel_data_size ); //-V570
if ( fnt->kern_data_size ) {
fnt->kern_data = (font_kernpair *)vm_malloc( fnt->kern_data_size );
Assert(fnt->kern_data!=NULL);
cfread( fnt->kern_data, fnt->kern_data_size, 1, fp );
} else {
fnt->kern_data = NULL;
}
if ( fnt->char_data_size ) {
fnt->char_data = (font_char *)vm_malloc( fnt->char_data_size );
Assert( fnt->char_data != NULL );
cfread( fnt->char_data, fnt->char_data_size, 1, fp );
for (int i=0; i<fnt->num_chars; i++) {
fnt->char_data[i].spacing = INTEL_INT( fnt->char_data[i].spacing ); //-V570
fnt->char_data[i].byte_width = INTEL_INT( fnt->char_data[i].byte_width ); //-V570
fnt->char_data[i].offset = INTEL_INT( fnt->char_data[i].offset ); //-V570
fnt->char_data[i].kerning_entry = INTEL_INT( fnt->char_data[i].kerning_entry ); //-V570
fnt->char_data[i].user_data = INTEL_SHORT( fnt->char_data[i].user_data ); //-V570
}
} else {
fnt->char_data = NULL;
}
if ( fnt->pixel_data_size ) {
fnt->pixel_data = (ubyte *)vm_malloc( fnt->pixel_data_size );
Assert(fnt->pixel_data!=NULL);
cfread( fnt->pixel_data, fnt->pixel_data_size, 1, fp );
} else {
fnt->pixel_data = NULL;
}
cfclose(fp);
// Create a bitmap for hardware cards.
// JAS: Try to squeeze this into the smallest square power of two texture.
// This should probably be done at font generation time, not here.
int w, h;
if ( fnt->pixel_data_size*4 < 64*64 ) {
w = h = 64;
} else if ( fnt->pixel_data_size*4 < 128*128 ) {
w = h = 128;
} else if ( fnt->pixel_data_size*4 < 256*256 ) {
w = h = 256;
} else if ( fnt->pixel_data_size*4 < 512*512 ) {
w = h = 512;
} else {
w = h = 1024;
}
fnt->bm_w = w;
fnt->bm_h = h;
fnt->bm_data = (ubyte *)vm_malloc(fnt->bm_w*fnt->bm_h);
fnt->bm_u = (int *)vm_malloc(sizeof(int)*fnt->num_chars);
fnt->bm_v = (int *)vm_malloc(sizeof(int)*fnt->num_chars);
memset( fnt->bm_data, 0, fnt->bm_w * fnt->bm_h );
int i,x,y;
x = y = 0;
for (i=0; i<fnt->num_chars; i++ ) {
ubyte * ubp;
int x1, y1;
ubp = &fnt->pixel_data[fnt->char_data[i].offset];
if ( x + fnt->char_data[i].byte_width >= fnt->bm_w ) {
x = 0;
y += fnt->h + 2;
if ( y+fnt->h > fnt->bm_h ) {
Error( LOCATION, "Font too big!\n" );
}
}
fnt->bm_u[i] = x;
fnt->bm_v[i] = y;
for( y1=0; y1<fnt->h; y1++ ) {
for (x1=0; x1<fnt->char_data[i].byte_width; x1++ ) {
uint c = *ubp++;
if ( c > 14 ) c = 14;
fnt->bm_data[(x+x1)+(y+y1)*fnt->bm_w] = (unsigned char)(c);
}
}
x += fnt->char_data[i].byte_width + 2;
}
fnt->bitmap_id = bm_create( 8, fnt->bm_w, fnt->bm_h, fnt->bm_data, BMP_AABITMAP );
return fontnum;
}
int gr_get_current_fontnum()
{
if (Current_font == NULL) {
return -1;
} else {
return (Current_font - &Fonts[0]);
}
}
int gr_get_fontnum(const char *filename)
{
int i;
for(i = 0; i < Num_fonts; i++)
{
if(!strextcmp(Fonts[i].filename, filename))
return i;
}
return -1;
}
void gr_set_font(int fontnum)
{
if ( fontnum < 0 ) {
Current_font = NULL;
Lcl_special_chars = 0;
return;
}
if ( fontnum >= 0 && fontnum < Num_fonts) {
Current_font = &Fonts[fontnum];
Lcl_special_chars = lcl_get_font_index(fontnum);
}
}
void parse_fonts_tbl(char *only_parse_first_font, size_t only_parse_first_font_size)
{
int i;
char *filename;
// choose file name
// (this can be done within the function, as opposed to being passed as a parameter,
// because fonts.tbl doesn't have a modular counterpart)
if ( cf_exists_full("fonts.tbl", CF_TYPE_TABLES) ) {
filename = "fonts.tbl";
} else {
filename = NULL;
}
try
{
if (filename != NULL) {
read_file_text(filename, CF_TYPE_TABLES);
}
else {
read_file_text_from_default(defaults_get_file("fonts.tbl"));
}
reset_parse();
// start parsing
required_string("#Fonts");
// read fonts
while (required_string_either("#End", "$Font:")) {
char font_filename[MAX_FILENAME_LEN];
// grab font
required_string("$Font:");
stuff_string(font_filename, F_NAME, MAX_FILENAME_LEN);
// if we only need the first font, copy it and bail
if (only_parse_first_font != NULL) {
strcpy_s(only_parse_first_font, only_parse_first_font_size, font_filename);
return;
}
// create font
int font_id = gr_create_font(font_filename);
if (font_id < 0) {
Warning(LOCATION, "Could not create font from typeface '%s'!", font_filename);
skip_to_start_of_string_either("#End", "$Font:");
}
else {
// max allowed special char index; i.e. 7 special chars in retail fonts 1 & 3
static const int MAX_SPECIAL_CHAR_IDX = UCHAR_MAX - 6;
// 'default' special char index for all languages using this font
int default_special_char_index = 0;
if (optional_string("+Default Special Character Index:")) {
stuff_int(&default_special_char_index);
if (default_special_char_index < 0 || default_special_char_index >= MAX_SPECIAL_CHAR_IDX) {
Error(LOCATION, "Default special character index (%d) for font (%s), must be 0 - %u", default_special_char_index, font_filename, MAX_SPECIAL_CHAR_IDX);
}
for (i = 0; i < (int)Lcl_languages.size(); ++i) {
Lcl_languages[i].special_char_indexes[font_id] = (ubyte)default_special_char_index;
}
}
while (optional_string("+Language:")) {
char lang_name[LCL_LANG_NAME_LEN + 1];
int special_char_index, lang_idx = -1;
stuff_string(lang_name, F_NAME, LCL_LANG_NAME_LEN + 1);
// find language and set the index, or if not found move to the next one
for (i = 0; i < (int)Lcl_languages.size(); ++i) {
if (!strcmp(Lcl_languages[i].lang_name, lang_name)) {
lang_idx = i;
break;
}
}
if (lang_idx == -1) {
Warning(LOCATION, "Ignoring invalid language (%s) specified by font (%s); not built-in or in strings.tbl", lang_name, font_filename);
skip_to_start_of_string_either("+Language:", "$Font:", "#End");
continue;
}
if (optional_string("+Special Character Index:")) {
stuff_int(&special_char_index);
if (special_char_index < 0 || special_char_index >= MAX_SPECIAL_CHAR_IDX) {
Error(LOCATION, "Special character index (%d) for font (%s), language (%s) is invalid, must be 0 - %u", special_char_index, font_filename, lang_name, MAX_SPECIAL_CHAR_IDX);
}
Lcl_languages[lang_idx].special_char_indexes[font_id] = (ubyte)special_char_index;
}
}
}
}
// done parsing
required_string("#End");
// double check
if (Num_fonts < 3) {
Error(LOCATION, "There must be at least three fonts in %s!", (filename) ? filename : NOX("<default fonts.tbl>"));
}
}
catch (const parse::ParseException& e)
{
mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", (filename) ? filename : NOX("<default fonts.tbl>"), e.what()));
return;
}
}
void gr_stuff_first_font(char *first_font, size_t first_font_size )
{
parse_fonts_tbl( first_font, first_font_size );
}
void gr_font_init()
{
parse_fonts_tbl( NULL, 0 );
gr_set_font(0);
}
+5 -69
View File
@@ -1,11 +1,11 @@
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
*/
@@ -14,71 +14,7 @@
#include "globalincs/pstypes.h"
#define MAX_FONTS 5
#define FONT_VERSION 0
#define WIDEST_DIGIT "4" // the widest number character
#define WIDEST_CHAR "W" // the widest character
typedef struct font_char {
int spacing;
int byte_width;
int offset;
short kerning_entry;
short user_data;
} font_char;
typedef struct font_kernpair {
char c1,c2;
signed char offset;
} font_kernpair;
typedef struct font {
char filename[MAX_FILENAME_LEN];
int id; // Should be 'VFNT'
int version; // font version
int num_chars;
int first_ascii;
int w;
int h;
int num_kern_pairs;
int kern_data_size;
int char_data_size;
int pixel_data_size;
font_kernpair *kern_data;
font_char *char_data;
ubyte *pixel_data;
// Data for 3d cards
int bitmap_id; // A bitmap representing the font data
int bm_w, bm_h; // Bitmap width and height
ubyte *bm_data; // The actual font data
int *bm_u; // U offset of each character
int *bm_v; // V offset of each character
} font;
extern int Num_fonts;
extern font Fonts[MAX_FONTS];
extern font *Current_font;
#define FONT1 0 // font01.vf
#define FONT2 1 // font02.vf
#define FONT3 2 // font03.vf
// extern definitions for basic font functions
extern void gr_stuff_first_font(char *first_font, size_t first_font_size);
extern int gr_get_current_fontnum();
extern int gr_get_fontnum(const char *filename);
extern void gr_set_font(int fontnum);
void gr_print_timestamp(int x, int y, fix timestamp, int resize_mode);
int gr_force_fit_string(char *str, int max_str, int max_width);
void gr_font_init();
void gr_font_close();
extern font *Current_font;
extern int get_char_width(ubyte c1,ubyte c2,int *width,int *spacing);
extern int get_centered_x(const char *s, bool scaled);
#include "graphics/software/font.h"
#include "graphics/software/FontManager.h"
#endif
+1 -1
View File
@@ -159,7 +159,7 @@ int generic_anim_stream(generic_anim *ga, const bool cache)
CFILE *img_cfp = NULL;
int anim_fps = 0;
char full_path[MAX_PATH];
int size = 0, offset = 0;
size_t size = 0, offset = 0;
const int NUM_TYPES = 3;
const ubyte type_list[NUM_TYPES] = {BM_TYPE_EFF, BM_TYPE_ANI, BM_TYPE_PNG};
const char *ext_list[NUM_TYPES] = {".eff", ".ani", ".png"};
File diff suppressed because it is too large. Load diff
-373
View File
@@ -1,373 +0,0 @@
/*++ BUILD Version: 0004 // Increment this if a change has global effects
Copyright (c) 1985-95, Microsoft Corporation
Module Name:
glaux.h
Abstract:
Procedure declarations, constant definitions and macros for the OpenGL
Auxiliary Library.
--*/
#ifndef __GLAUX_H__
#define __GLAUX_H__
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
* and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
*
* US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
* clause at DFARS 252.227-7013 and/or in similar or successor
* clauses in the FAR or the DOD or NASA FAR Supplement.
* Unpublished-- rights reserved under the copyright laws of the
* United States. Contractor/manufacturer is Silicon Graphics,
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
*
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
** ToolKit Window Types
** In the future, AUX_RGBA may be a combination of both RGB and ALPHA
*/
#define AUX_RGB 0
#define AUX_RGBA AUX_RGB
#define AUX_INDEX 1
#define AUX_SINGLE 0
#define AUX_DOUBLE 2
#define AUX_DIRECT 0
#define AUX_INDIRECT 4
#define AUX_ACCUM 8
#define AUX_ALPHA 16
#define AUX_DEPTH24 32 /* 24-bit depth buffer */
#define AUX_STENCIL 64
#define AUX_AUX 128
#define AUX_DEPTH16 256 /* 16-bit depth buffer */
#define AUX_FIXED_332_PAL 512
#define AUX_DEPTH AUX_DEPTH16 /* default is 16-bit depth buffer */
/*
** Window Masks
*/
#define AUX_WIND_IS_RGB(x) (((x) & AUX_INDEX) == 0)
#define AUX_WIND_IS_INDEX(x) (((x) & AUX_INDEX) != 0)
#define AUX_WIND_IS_SINGLE(x) (((x) & AUX_DOUBLE) == 0)
#define AUX_WIND_IS_DOUBLE(x) (((x) & AUX_DOUBLE) != 0)
#define AUX_WIND_IS_INDIRECT(x) (((x) & AUX_INDIRECT) != 0)
#define AUX_WIND_IS_DIRECT(x) (((x) & AUX_INDIRECT) == 0)
#define AUX_WIND_HAS_ACCUM(x) (((x) & AUX_ACCUM) != 0)
#define AUX_WIND_HAS_ALPHA(x) (((x) & AUX_ALPHA) != 0)
#define AUX_WIND_HAS_DEPTH(x) (((x) & (AUX_DEPTH24 | AUX_DEPTH16)) != 0)
#define AUX_WIND_HAS_STENCIL(x) (((x) & AUX_STENCIL) != 0)
#define AUX_WIND_USES_FIXED_332_PAL(x) (((x) & AUX_FIXED_332_PAL) != 0)
/*
** ToolKit Event Structure
*/
typedef struct _AUX_EVENTREC {
GLint event;
GLint data[4];
} AUX_EVENTREC;
/*
** ToolKit Event Types
*/
#define AUX_EXPOSE 1
#define AUX_CONFIG 2
#define AUX_DRAW 4
#define AUX_KEYEVENT 8
#define AUX_MOUSEDOWN 16
#define AUX_MOUSEUP 32
#define AUX_MOUSELOC 64
/*
** Toolkit Event Data Indices
*/
#define AUX_WINDOWX 0
#define AUX_WINDOWY 1
#define AUX_MOUSEX 0
#define AUX_MOUSEY 1
#define AUX_MOUSESTATUS 3
#define AUX_KEY 0
#define AUX_KEYSTATUS 1
/*
** ToolKit Event Status Messages
*/
#define AUX_LEFTBUTTON 1
#define AUX_RIGHTBUTTON 2
#define AUX_MIDDLEBUTTON 4
#define AUX_SHIFT 1
#define AUX_CONTROL 2
/*
** ToolKit Key Codes
*/
#define AUX_RETURN 0x0D
#define AUX_ESCAPE 0x1B
#define AUX_SPACE 0x20
#define AUX_LEFT 0x25
#define AUX_UP 0x26
#define AUX_RIGHT 0x27
#define AUX_DOWN 0x28
#define AUX_A 'A'
#define AUX_B 'B'
#define AUX_C 'C'
#define AUX_D 'D'
#define AUX_E 'E'
#define AUX_F 'F'
#define AUX_G 'G'
#define AUX_H 'H'
#define AUX_I 'I'
#define AUX_J 'J'
#define AUX_K 'K'
#define AUX_L 'L'
#define AUX_M 'M'
#define AUX_N 'N'
#define AUX_O 'O'
#define AUX_P 'P'
#define AUX_Q 'Q'
#define AUX_R 'R'
#define AUX_S 'S'
#define AUX_T 'T'
#define AUX_U 'U'
#define AUX_V 'V'
#define AUX_W 'W'
#define AUX_X 'X'
#define AUX_Y 'Y'
#define AUX_Z 'Z'
#define AUX_a 'a'
#define AUX_b 'b'
#define AUX_c 'c'
#define AUX_d 'd'
#define AUX_e 'e'
#define AUX_f 'f'
#define AUX_g 'g'
#define AUX_h 'h'
#define AUX_i 'i'
#define AUX_j 'j'
#define AUX_k 'k'
#define AUX_l 'l'
#define AUX_m 'm'
#define AUX_n 'n'
#define AUX_o 'o'
#define AUX_p 'p'
#define AUX_q 'q'
#define AUX_r 'r'
#define AUX_s 's'
#define AUX_t 't'
#define AUX_u 'u'
#define AUX_v 'v'
#define AUX_w 'w'
#define AUX_x 'x'
#define AUX_y 'y'
#define AUX_z 'z'
#define AUX_0 '0'
#define AUX_1 '1'
#define AUX_2 '2'
#define AUX_3 '3'
#define AUX_4 '4'
#define AUX_5 '5'
#define AUX_6 '6'
#define AUX_7 '7'
#define AUX_8 '8'
#define AUX_9 '9'
/*
** ToolKit Gets and Sets
*/
#define AUX_FD 1 /* return fd (long) */
#define AUX_COLORMAP 3 /* pass buf of r, g and b (unsigned char) */
#define AUX_GREYSCALEMAP 4
#define AUX_FOGMAP 5 /* pass fog and color bits (long) */
#define AUX_ONECOLOR 6 /* pass index, r, g, and b (long) */
/*
** Color Macros
*/
#define AUX_BLACK 0
#define AUX_RED 13
#define AUX_GREEN 14
#define AUX_YELLOW 15
#define AUX_BLUE 16
#define AUX_MAGENTA 17
#define AUX_CYAN 18
#define AUX_WHITE 19
extern float auxRGBMap[20][3];
#define AUX_SETCOLOR(x, y) (AUX_WIND_IS_RGB((x)) ? \
glColor3fv(auxRGBMap[(y)]) : glIndexf((y)))
/*
** RGB Image Structure
*/
typedef struct _AUX_RGBImageRec {
GLint sizeX, sizeY;
unsigned char *data;
} AUX_RGBImageRec;
/*
** Prototypes
*/
void APIENTRY auxInitDisplayMode(GLenum);
void APIENTRY auxInitPosition(int, int, int, int);
/* GLenum APIENTRY auxInitWindow(LPCTSTR); */
#ifdef UNICODE
#define auxInitWindow auxInitWindowW
#else
#define auxInitWindow auxInitWindowA
#endif
GLenum APIENTRY auxInitWindowA(LPCSTR);
GLenum APIENTRY auxInitWindowW(LPCWSTR);
void APIENTRY auxCloseWindow(void);
void APIENTRY auxQuit(void);
void APIENTRY auxSwapBuffers(void);
typedef void (CALLBACK* AUXMAINPROC)(void);
void APIENTRY auxMainLoop(AUXMAINPROC);
typedef void (CALLBACK* AUXEXPOSEPROC)(int, int);
void APIENTRY auxExposeFunc(AUXEXPOSEPROC);
typedef void (CALLBACK* AUXRESHAPEPROC)(GLsizei, GLsizei);
void APIENTRY auxReshapeFunc(AUXRESHAPEPROC);
typedef void (CALLBACK* AUXIDLEPROC)(void);
void APIENTRY auxIdleFunc(AUXIDLEPROC);
typedef void (CALLBACK* AUXKEYPROC)(void);
void APIENTRY auxKeyFunc(int, AUXKEYPROC);
typedef void (CALLBACK* AUXMOUSEPROC)(AUX_EVENTREC *);
void APIENTRY auxMouseFunc(int, int, AUXMOUSEPROC);
int APIENTRY auxGetColorMapSize(void);
void APIENTRY auxGetMouseLoc(int *, int *);
void APIENTRY auxSetOneColor(int, float, float, float);
void APIENTRY auxSetFogRamp(int, int);
void APIENTRY auxSetGreyRamp(void);
void APIENTRY auxSetRGBMap(int, float *);
/* AUX_RGBImageRec * APIENTRY auxRGBImageLoad(LPCTSTR); */
#ifdef UNICODE
#define auxRGBImageLoad auxRGBImageLoadW
#else
#define auxRGBImageLoad auxRGBImageLoadA
#endif
AUX_RGBImageRec * APIENTRY auxRGBImageLoadA(LPCSTR);
AUX_RGBImageRec * APIENTRY auxRGBImageLoadW(LPCWSTR);
#ifdef UNICODE
#define auxDIBImageLoad auxDIBImageLoadW
#else
#define auxDIBImageLoad auxDIBImageLoadA
#endif
AUX_RGBImageRec * APIENTRY auxDIBImageLoadA(LPCSTR);
AUX_RGBImageRec * APIENTRY auxDIBImageLoadW(LPCWSTR);
void APIENTRY auxCreateFont(void);
/* void APIENTRY auxDrawStr(LPCTSTR); */
#ifdef UNICODE
#define auxDrawStr auxDrawStrW
#else
#define auxDrawStr auxDrawStrA
#endif
void APIENTRY auxDrawStrA(LPCSTR);
void APIENTRY auxDrawStrW(LPCWSTR);
void APIENTRY auxWireSphere(GLdouble);
void APIENTRY auxSolidSphere(GLdouble);
void APIENTRY auxWireCube(GLdouble);
void APIENTRY auxSolidCube(GLdouble);
void APIENTRY auxWireBox(GLdouble, GLdouble, GLdouble);
void APIENTRY auxSolidBox(GLdouble, GLdouble, GLdouble);
void APIENTRY auxWireTorus(GLdouble, GLdouble);
void APIENTRY auxSolidTorus(GLdouble, GLdouble);
void APIENTRY auxWireCylinder(GLdouble, GLdouble);
void APIENTRY auxSolidCylinder(GLdouble, GLdouble);
void APIENTRY auxWireIcosahedron(GLdouble);
void APIENTRY auxSolidIcosahedron(GLdouble);
void APIENTRY auxWireOctahedron(GLdouble);
void APIENTRY auxSolidOctahedron(GLdouble);
void APIENTRY auxWireTetrahedron(GLdouble);
void APIENTRY auxSolidTetrahedron(GLdouble);
void APIENTRY auxWireDodecahedron(GLdouble);
void APIENTRY auxSolidDodecahedron(GLdouble);
void APIENTRY auxWireCone(GLdouble, GLdouble);
void APIENTRY auxSolidCone(GLdouble, GLdouble);
void APIENTRY auxWireTeapot(GLdouble);
void APIENTRY auxSolidTeapot(GLdouble);
/*
** Window specific functions
** hwnd, hdc, and hglrc valid after auxInitWindow()
*/
HWND APIENTRY auxGetHWND(void);
HDC APIENTRY auxGetHDC(void);
HGLRC APIENTRY auxGetHGLRC(void);
/*
** Viewperf support functions and constants
*/
/* Display Mode Selection Criteria */
enum {
AUX_USE_ID = 1,
AUX_EXACT_MATCH,
AUX_MINIMUM_CRITERIA
};
void APIENTRY auxInitDisplayModePolicy(GLenum);
GLenum APIENTRY auxInitDisplayModeID(GLint);
GLenum APIENTRY auxGetDisplayModePolicy(void);
GLint APIENTRY auxGetDisplayModeID(void);
GLenum APIENTRY auxGetDisplayMode(void);
#ifdef __cplusplus
}
#endif
#endif /* __GLAUX_H__ */
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -19,7 +19,7 @@ Abstract:
#define __glu_h__
#define __GLU_H__
#include <GL/gl.h>
#include <glad/glad.h>
#ifdef __cplusplus
extern "C" {
-929
View File
@@ -1,929 +0,0 @@
#ifndef __wglext_h_
#define __wglext_h_
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2007-2010 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Function declaration macros - to move into glplatform.h */
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifndef GLAPI
#define GLAPI extern
#endif
/*************************************************************/
/* Header file version number */
/* wglext.h last updated 2011/04/13 */
/* Current version at http://www.opengl.org/registry/ */
#define WGL_WGLEXT_VERSION 23
#ifndef WGL_ARB_buffer_region
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002
#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004
#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008
#endif
#ifndef WGL_ARB_multisample
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
#endif
#ifndef WGL_ARB_extensions_string
#endif
#ifndef WGL_ARB_pixel_format
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
#define WGL_ACCELERATION_ARB 0x2003
#define WGL_NEED_PALETTE_ARB 0x2004
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
#define WGL_SWAP_METHOD_ARB 0x2007
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
#define WGL_TRANSPARENT_ARB 0x200A
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
#define WGL_SHARE_DEPTH_ARB 0x200C
#define WGL_SHARE_STENCIL_ARB 0x200D
#define WGL_SHARE_ACCUM_ARB 0x200E
#define WGL_SUPPORT_GDI_ARB 0x200F
#define WGL_SUPPORT_OPENGL_ARB 0x2010
#define WGL_DOUBLE_BUFFER_ARB 0x2011
#define WGL_STEREO_ARB 0x2012
#define WGL_PIXEL_TYPE_ARB 0x2013
#define WGL_COLOR_BITS_ARB 0x2014
#define WGL_RED_BITS_ARB 0x2015
#define WGL_RED_SHIFT_ARB 0x2016
#define WGL_GREEN_BITS_ARB 0x2017
#define WGL_GREEN_SHIFT_ARB 0x2018
#define WGL_BLUE_BITS_ARB 0x2019
#define WGL_BLUE_SHIFT_ARB 0x201A
#define WGL_ALPHA_BITS_ARB 0x201B
#define WGL_ALPHA_SHIFT_ARB 0x201C
#define WGL_ACCUM_BITS_ARB 0x201D
#define WGL_ACCUM_RED_BITS_ARB 0x201E
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
#define WGL_DEPTH_BITS_ARB 0x2022
#define WGL_STENCIL_BITS_ARB 0x2023
#define WGL_AUX_BUFFERS_ARB 0x2024
#define WGL_NO_ACCELERATION_ARB 0x2025
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
#define WGL_FULL_ACCELERATION_ARB 0x2027
#define WGL_SWAP_EXCHANGE_ARB 0x2028
#define WGL_SWAP_COPY_ARB 0x2029
#define WGL_SWAP_UNDEFINED_ARB 0x202A
#define WGL_TYPE_RGBA_ARB 0x202B
#define WGL_TYPE_COLORINDEX_ARB 0x202C
#endif
#ifndef WGL_ARB_make_current_read
#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
#endif
#ifndef WGL_ARB_pbuffer
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
#define WGL_PBUFFER_LARGEST_ARB 0x2033
#define WGL_PBUFFER_WIDTH_ARB 0x2034
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
#define WGL_PBUFFER_LOST_ARB 0x2036
#endif
#ifndef WGL_ARB_render_texture
#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070
#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
#define WGL_TEXTURE_FORMAT_ARB 0x2072
#define WGL_TEXTURE_TARGET_ARB 0x2073
#define WGL_MIPMAP_TEXTURE_ARB 0x2074
#define WGL_TEXTURE_RGB_ARB 0x2075
#define WGL_TEXTURE_RGBA_ARB 0x2076
#define WGL_NO_TEXTURE_ARB 0x2077
#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078
#define WGL_TEXTURE_1D_ARB 0x2079
#define WGL_TEXTURE_2D_ARB 0x207A
#define WGL_MIPMAP_LEVEL_ARB 0x207B
#define WGL_CUBE_MAP_FACE_ARB 0x207C
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
#define WGL_FRONT_LEFT_ARB 0x2083
#define WGL_FRONT_RIGHT_ARB 0x2084
#define WGL_BACK_LEFT_ARB 0x2085
#define WGL_BACK_RIGHT_ARB 0x2086
#define WGL_AUX0_ARB 0x2087
#define WGL_AUX1_ARB 0x2088
#define WGL_AUX2_ARB 0x2089
#define WGL_AUX3_ARB 0x208A
#define WGL_AUX4_ARB 0x208B
#define WGL_AUX5_ARB 0x208C
#define WGL_AUX6_ARB 0x208D
#define WGL_AUX7_ARB 0x208E
#define WGL_AUX8_ARB 0x208F
#define WGL_AUX9_ARB 0x2090
#endif
#ifndef WGL_ARB_pixel_format_float
#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0
#endif
#ifndef WGL_ARB_framebuffer_sRGB
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
#endif
#ifndef WGL_ARB_create_context
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define ERROR_INVALID_VERSION_ARB 0x2095
#endif
#ifndef WGL_ARB_create_context_profile
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
#define ERROR_INVALID_PROFILE_ARB 0x2096
#endif
#ifndef WGL_ARB_create_context_robustness
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
#endif
#ifndef WGL_EXT_make_current_read
#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
#endif
#ifndef WGL_EXT_pixel_format
#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000
#define WGL_DRAW_TO_WINDOW_EXT 0x2001
#define WGL_DRAW_TO_BITMAP_EXT 0x2002
#define WGL_ACCELERATION_EXT 0x2003
#define WGL_NEED_PALETTE_EXT 0x2004
#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005
#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006
#define WGL_SWAP_METHOD_EXT 0x2007
#define WGL_NUMBER_OVERLAYS_EXT 0x2008
#define WGL_NUMBER_UNDERLAYS_EXT 0x2009
#define WGL_TRANSPARENT_EXT 0x200A
#define WGL_TRANSPARENT_VALUE_EXT 0x200B
#define WGL_SHARE_DEPTH_EXT 0x200C
#define WGL_SHARE_STENCIL_EXT 0x200D
#define WGL_SHARE_ACCUM_EXT 0x200E
#define WGL_SUPPORT_GDI_EXT 0x200F
#define WGL_SUPPORT_OPENGL_EXT 0x2010
#define WGL_DOUBLE_BUFFER_EXT 0x2011
#define WGL_STEREO_EXT 0x2012
#define WGL_PIXEL_TYPE_EXT 0x2013
#define WGL_COLOR_BITS_EXT 0x2014
#define WGL_RED_BITS_EXT 0x2015
#define WGL_RED_SHIFT_EXT 0x2016
#define WGL_GREEN_BITS_EXT 0x2017
#define WGL_GREEN_SHIFT_EXT 0x2018
#define WGL_BLUE_BITS_EXT 0x2019
#define WGL_BLUE_SHIFT_EXT 0x201A
#define WGL_ALPHA_BITS_EXT 0x201B
#define WGL_ALPHA_SHIFT_EXT 0x201C
#define WGL_ACCUM_BITS_EXT 0x201D
#define WGL_ACCUM_RED_BITS_EXT 0x201E
#define WGL_ACCUM_GREEN_BITS_EXT 0x201F
#define WGL_ACCUM_BLUE_BITS_EXT 0x2020
#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021
#define WGL_DEPTH_BITS_EXT 0x2022
#define WGL_STENCIL_BITS_EXT 0x2023
#define WGL_AUX_BUFFERS_EXT 0x2024
#define WGL_NO_ACCELERATION_EXT 0x2025
#define WGL_GENERIC_ACCELERATION_EXT 0x2026
#define WGL_FULL_ACCELERATION_EXT 0x2027
#define WGL_SWAP_EXCHANGE_EXT 0x2028
#define WGL_SWAP_COPY_EXT 0x2029
#define WGL_SWAP_UNDEFINED_EXT 0x202A
#define WGL_TYPE_RGBA_EXT 0x202B
#define WGL_TYPE_COLORINDEX_EXT 0x202C
#endif
#ifndef WGL_EXT_pbuffer
#define WGL_DRAW_TO_PBUFFER_EXT 0x202D
#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E
#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F
#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030
#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031
#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
#define WGL_PBUFFER_LARGEST_EXT 0x2033
#define WGL_PBUFFER_WIDTH_EXT 0x2034
#define WGL_PBUFFER_HEIGHT_EXT 0x2035
#endif
#ifndef WGL_EXT_depth_float
#define WGL_DEPTH_FLOAT_EXT 0x2040
#endif
#ifndef WGL_3DFX_multisample
#define WGL_SAMPLE_BUFFERS_3DFX 0x2060
#define WGL_SAMPLES_3DFX 0x2061
#endif
#ifndef WGL_EXT_multisample
#define WGL_SAMPLE_BUFFERS_EXT 0x2041
#define WGL_SAMPLES_EXT 0x2042
#endif
#ifndef WGL_I3D_digital_video_control
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
#endif
#ifndef WGL_I3D_gamma
#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E
#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F
#endif
#ifndef WGL_I3D_genlock
#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045
#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046
#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047
#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
#endif
#ifndef WGL_I3D_image_buffer
#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002
#endif
#ifndef WGL_I3D_swap_frame_lock
#endif
#ifndef WGL_NV_render_depth_texture
#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3
#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5
#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
#define WGL_DEPTH_COMPONENT_NV 0x20A7
#endif
#ifndef WGL_NV_render_texture_rectangle
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
#define WGL_TEXTURE_RECTANGLE_NV 0x20A2
#endif
#ifndef WGL_ATI_pixel_format_float
#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
#endif
#ifndef WGL_NV_float_buffer
#define WGL_FLOAT_COMPONENTS_NV 0x20B0
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
#define WGL_TEXTURE_FLOAT_R_NV 0x20B5
#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6
#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7
#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8
#endif
#ifndef WGL_3DL_stereo_control
#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055
#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056
#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057
#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058
#endif
#ifndef WGL_EXT_pixel_format_packed_float
#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
#endif
#ifndef WGL_EXT_framebuffer_sRGB
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
#endif
#ifndef WGL_NV_present_video
#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0
#endif
#ifndef WGL_NV_video_out
#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0
#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1
#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2
#define WGL_VIDEO_OUT_COLOR_NV 0x20C3
#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4
#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5
#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
#define WGL_VIDEO_OUT_FRAME 0x20C8
#define WGL_VIDEO_OUT_FIELD_1 0x20C9
#define WGL_VIDEO_OUT_FIELD_2 0x20CA
#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB
#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC
#endif
#ifndef WGL_NV_swap_group
#endif
#ifndef WGL_NV_gpu_affinity
#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0
#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1
#endif
#ifndef WGL_AMD_gpu_association
#define WGL_GPU_VENDOR_AMD 0x1F00
#define WGL_GPU_RENDERER_STRING_AMD 0x1F01
#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02
#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2
#define WGL_GPU_RAM_AMD 0x21A3
#define WGL_GPU_CLOCK_AMD 0x21A4
#define WGL_GPU_NUM_PIPES_AMD 0x21A5
#define WGL_GPU_NUM_SIMD_AMD 0x21A6
#define WGL_GPU_NUM_RB_AMD 0x21A7
#define WGL_GPU_NUM_SPI_AMD 0x21A8
#endif
#ifndef WGL_NV_video_capture
#define WGL_UNIQUE_ID_NV 0x20CE
#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
#endif
#ifndef WGL_NV_copy_image
#endif
#ifndef WGL_NV_multisample_coverage
#define WGL_COVERAGE_SAMPLES_NV 0x2042
#define WGL_COLOR_SAMPLES_NV 0x20B9
#endif
#ifndef WGL_EXT_create_context_es2_profile
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
#endif
#ifndef WGL_NV_DX_interop
#define WGL_ACCESS_READ_ONLY_NV 0x00000000
#define WGL_ACCESS_READ_WRITE_NV 0x00000001
#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002
#endif
/*************************************************************/
#ifndef WGL_ARB_pbuffer
DECLARE_HANDLE(HPBUFFERARB);
#endif
#ifndef WGL_EXT_pbuffer
DECLARE_HANDLE(HPBUFFEREXT);
#endif
#ifndef WGL_NV_present_video
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
#endif
#ifndef WGL_NV_video_output
DECLARE_HANDLE(HPVIDEODEV);
#endif
#ifndef WGL_NV_gpu_affinity
DECLARE_HANDLE(HPGPUNV);
DECLARE_HANDLE(HGPUNV);
typedef struct _GPU_DEVICE {
DWORD cb;
CHAR DeviceName[32];
CHAR DeviceString[128];
DWORD Flags;
RECT rcVirtualScreen;
} GPU_DEVICE, *PGPU_DEVICE;
#endif
#ifndef WGL_NV_video_capture
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
#endif
#ifndef WGL_ARB_buffer_region
#define WGL_ARB_buffer_region 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType);
extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion);
extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height);
extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
#endif
#ifndef WGL_ARB_multisample
#define WGL_ARB_multisample 1
#endif
#ifndef WGL_ARB_extensions_string
#define WGL_ARB_extensions_string 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern const char * WINAPI wglGetExtensionsStringARB (HDC hdc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
#endif
#ifndef WGL_ARB_pixel_format
#define WGL_ARB_pixel_format 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
extern BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif
#ifndef WGL_ARB_make_current_read
#define WGL_ARB_make_current_read 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
extern HDC WINAPI wglGetCurrentReadDCARB (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
#endif
#ifndef WGL_ARB_pbuffer
#define WGL_ARB_pbuffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer);
extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC);
extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer);
extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
#endif
#ifndef WGL_ARB_render_texture
#define WGL_ARB_render_texture 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
#endif
#ifndef WGL_ARB_pixel_format_float
#define WGL_ARB_pixel_format_float 1
#endif
#ifndef WGL_ARB_framebuffer_sRGB
#define WGL_ARB_framebuffer_sRGB 1
#endif
#ifndef WGL_ARB_create_context
#define WGL_ARB_create_context 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
#endif
#ifndef WGL_ARB_create_context_profile
#define WGL_ARB_create_context_profile 1
#endif
#ifndef WGL_ARB_create_context_robustness
#define WGL_ARB_create_context_robustness 1
#endif
#ifndef WGL_EXT_display_color_table
#define WGL_EXT_display_color_table 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id);
extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length);
extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id);
extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
#endif
#ifndef WGL_EXT_extensions_string
#define WGL_EXT_extensions_string 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern const char * WINAPI wglGetExtensionsStringEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
#endif
#ifndef WGL_EXT_make_current_read
#define WGL_EXT_make_current_read 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
extern HDC WINAPI wglGetCurrentReadDCEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
#endif
#ifndef WGL_EXT_pbuffer
#define WGL_EXT_pbuffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer);
extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC);
extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer);
extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
#endif
#ifndef WGL_EXT_pixel_format
#define WGL_EXT_pixel_format 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
extern BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif
#ifndef WGL_EXT_swap_control
#define WGL_EXT_swap_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglSwapIntervalEXT (int interval);
extern int WINAPI wglGetSwapIntervalEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
#endif
#ifndef WGL_EXT_depth_float
#define WGL_EXT_depth_float 1
#endif
#ifndef WGL_NV_vertex_array_range
#define WGL_NV_vertex_array_range 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern void* WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
extern void WINAPI wglFreeMemoryNV (void *pointer);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
#endif
#ifndef WGL_3DFX_multisample
#define WGL_3DFX_multisample 1
#endif
#ifndef WGL_EXT_multisample
#define WGL_EXT_multisample 1
#endif
#ifndef WGL_OML_sync_control
#define WGL_OML_sync_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
extern BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator);
extern INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
extern BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
extern BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
#endif
#ifndef WGL_I3D_digital_video_control
#define WGL_I3D_digital_video_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue);
extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
#endif
#ifndef WGL_I3D_gamma
#define WGL_I3D_gamma 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue);
extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue);
extern BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
extern BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
#endif
#ifndef WGL_I3D_genlock
#define WGL_I3D_genlock 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglEnableGenlockI3D (HDC hDC);
extern BOOL WINAPI wglDisableGenlockI3D (HDC hDC);
extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag);
extern BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource);
extern BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource);
extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge);
extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge);
extern BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate);
extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate);
extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay);
extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay);
extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
#endif
#ifndef WGL_I3D_image_buffer
#define WGL_I3D_image_buffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags);
extern BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress);
extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
#endif
#ifndef WGL_I3D_swap_frame_lock
#define WGL_I3D_swap_frame_lock 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglEnableFrameLockI3D (void);
extern BOOL WINAPI wglDisableFrameLockI3D (void);
extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag);
extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
#endif
#ifndef WGL_I3D_swap_frame_usage
#define WGL_I3D_swap_frame_usage 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetFrameUsageI3D (float *pUsage);
extern BOOL WINAPI wglBeginFrameTrackingI3D (void);
extern BOOL WINAPI wglEndFrameTrackingI3D (void);
extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
#endif
#ifndef WGL_ATI_pixel_format_float
#define WGL_ATI_pixel_format_float 1
#endif
#ifndef WGL_NV_float_buffer
#define WGL_NV_float_buffer 1
#endif
#ifndef WGL_3DL_stereo_control
#define WGL_3DL_stereo_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);
#endif
#ifndef WGL_EXT_pixel_format_packed_float
#define WGL_EXT_pixel_format_packed_float 1
#endif
#ifndef WGL_EXT_framebuffer_sRGB
#define WGL_EXT_framebuffer_sRGB 1
#endif
#ifndef WGL_NV_present_video
#define WGL_NV_present_video 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
extern BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
extern BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
#endif
#ifndef WGL_NV_video_output
#define WGL_NV_video_output 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice);
extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer);
extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);
typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);
typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#endif
#ifndef WGL_NV_swap_group
#define WGL_NV_swap_group 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group);
extern BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier);
extern BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier);
extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
extern BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count);
extern BOOL WINAPI wglResetFrameCountNV (HDC hDC);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);
typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);
typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);
typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);
typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);
#endif
#ifndef WGL_NV_gpu_affinity
#define WGL_NV_gpu_affinity 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu);
extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList);
extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
extern BOOL WINAPI wglDeleteDCNV (HDC hdc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);
typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);
typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);
#endif
#ifndef WGL_AMD_gpu_association
#define WGL_AMD_gpu_association 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids);
extern INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data);
extern UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc);
extern HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id);
extern HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList);
extern BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc);
extern BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc);
extern HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void);
extern VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids);
typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data);
typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList);
typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);
typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);
typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
#ifndef WGL_NV_video_capture
#define WGL_NV_video_capture 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
#endif
#ifndef WGL_NV_copy_image
#define WGL_NV_copy_image 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif
#ifndef WGL_NV_multisample_coverage
#define WGL_NV_multisample_coverage 1
#endif
#ifndef WGL_NV_DX_interop
#define WGL_NV_DX_interop 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle);
extern HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice);
extern BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice);
extern HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
extern BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject);
extern BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access);
extern BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
extern BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle);
typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice);
typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);
typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);
typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);
typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
#endif
#ifdef __cplusplus
}
#endif
#endif
+11 -11
View File
@@ -601,10 +601,10 @@ void geometry_shader_batcher::render_buffer(int buffer_handle, int flags)
buffer_offset = -1;
}
void geometry_shader_batcher::load_buffer(particle_pnt* buffer, int *n_verts)
void geometry_shader_batcher::load_buffer(particle_pnt* buffer, size_t *n_verts)
{
int verts_to_render = vertices.size();
int i;
size_t verts_to_render = vertices.size();
size_t i;
buffer_offset = *n_verts;
@@ -733,7 +733,7 @@ int batch_add_bitmap(int texture, int tmap_flags, vertex *pnt, int orient, float
tmap_flags &= ~(TMAP_FLAG_SOFT_QUAD);
}
if ( GLSL_version > 120 && Cmdline_softparticles && !Cmdline_no_geo_sdr_effects && Is_Extension_Enabled(OGL_EXT_GEOMETRY_SHADER4) && (tmap_flags & TMAP_FLAG_VERTEX_GEN) ) {
if ( GLSL_version > 120 && Cmdline_softparticles && !Cmdline_no_geo_sdr_effects && GLAD_GL_ARB_geometry_shader4 && (tmap_flags & TMAP_FLAG_VERTEX_GEN) ) {
geometry_batch_add_bitmap(texture, tmap_flags, pnt, orient, rad, alpha, depth);
return 0;
} else if ( tmap_flags & TMAP_FLAG_VERTEX_GEN ) {
@@ -1081,7 +1081,7 @@ void batch_load_buffer_geometry_map_bitmaps(effect_vertex* buffer, int *n_verts)
}
}
void batch_load_buffer_geometry_shader_map_bitmaps(particle_pnt* buffer, int *n_verts)
void batch_load_buffer_geometry_shader_map_bitmaps(particle_pnt* buffer, size_t *n_verts)
{
for (SCP_map<int, g_sdr_batch_item>::iterator bi = geometry_shader_map.begin(); bi != geometry_shader_map.end(); ++bi) {
@@ -1102,8 +1102,8 @@ void geometry_batch_render(int stream_buffer)
return;
}
int n_to_render = geometry_batch_get_size();
int n_verts = 0;
size_t n_to_render = geometry_batch_get_size();
size_t n_verts = 0;
if ( Batch_geometry_buffer_size < (n_to_render * sizeof(particle_pnt)) ) {
if ( Batch_geometry_buffer != NULL ) {
@@ -1179,7 +1179,7 @@ int distortion_add_bitmap_rotated(int texture, int tmap_flags, vertex *pnt, floa
return 1;
}
if ( GLSL_version < 120 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
if ( GLSL_version < 120 || !GLAD_GL_EXT_framebuffer_object ) {
// don't render distortions if we can't support them.
return 0;
}
@@ -1214,7 +1214,7 @@ int distortion_add_beam(int texture, int tmap_flags, vec3d *start, vec3d *end, f
return 1;
}
if ( GLSL_version < 120 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
if ( GLSL_version < 120 || !GLAD_GL_EXT_framebuffer_object ) {
// don't render distortions if we can't support them.
return 0;
}
@@ -1297,9 +1297,9 @@ int batch_get_size()
return n_to_render * 3;
}
int geometry_batch_get_size()
size_t geometry_batch_get_size()
{
int n_to_render = 0;
size_t n_to_render = 0;
SCP_map<int, g_sdr_batch_item>::iterator bi;
for (bi = geometry_shader_map.begin(); bi != geometry_shader_map.end(); ++bi) {
+4 -4
View File
@@ -78,7 +78,7 @@ class geometry_shader_batcher
{
SCP_vector<particle_pnt> vertices;
int buffer_offset;
ptrdiff_t buffer_offset;
public:
// draw a bitmap into the geometry batcher
void draw_bitmap(vertex *position, int orient, float rad, float depth = 0);
@@ -86,11 +86,11 @@ public:
// draw a rotated bitmap
// void draw_bitmap(vertex *position, float rad, float angle, float depth);
void load_buffer(particle_pnt* buffer, int *n_verts);
void load_buffer(particle_pnt* buffer, size_t *n_verts);
void render_buffer(int buffer_handle, int flags);
int need_to_render() { return vertices.size(); };
size_t need_to_render() { return vertices.size(); }
};
@@ -119,6 +119,6 @@ int geometry_batch_add_bitmap(int texture, int tmap_flags, vertex *pnt, int orie
void batch_load_buffer_geometry_shader_map_bitmaps(particle_pnt* buffer, int *n_verts);
void batch_render_geometry_shader_map_bitmaps();
void geometry_batch_render(int stream_buffer);
int geometry_batch_get_size();
size_t geometry_batch_get_size();
#endif
+318 -175
View File
@@ -10,10 +10,10 @@
#include "debugconsole/console.h"
#include "globalincs/systemvars.h"
#include "graphics/2d.h"
#include "graphics/paths/PathRenderer.h"
#include "graphics/gropengl.h"
#include "graphics/gropenglbmpman.h"
#include "graphics/gropengldraw.h"
#include "graphics/gropenglextension.h"
#include "graphics/gropengllight.h"
#include "graphics/gropenglpostprocessing.h"
#include "graphics/gropenglshader.h"
@@ -30,26 +30,20 @@
#include "osapi/osregistry.h"
#include "palman/palman.h"
#include "render/3d.h"
#include "popup/popup.h"
#include "gl/glu.h"
#if defined(_WIN32)
#include <windows.h>
#include <windowsx.h>
#include <direct.h>
#elif defined(__APPLE__)
#include "OpenGL.h"
#else
typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval);
#endif
#include <glad/glad.h>
#if defined(_WIN32) && !defined(__GNUC__)
#pragma comment (lib, "opengl32")
#pragma comment (lib, "glu32")
#endif
// minimum GL version we can reliably support is 1.2
static const int MIN_REQUIRED_GL_VERSION = 12;
// minimum GL version we can reliably support is 2.0
static const int MIN_REQUIRED_GL_VERSION = 20;
// minimum GLSL version we can reliably support is 110
static const int MIN_REQUIRED_GLSL_VERSION = 110;
@@ -70,6 +64,8 @@ static ushort *GL_original_gamma_ramp = NULL;
int Use_VBOs = 0;
int Use_PBOs = 0;
float GL_line_width = 1.0f;
static ubyte *GL_saved_screen = NULL;
static int GL_saved_screen_id = -1;
static GLuint GL_screen_pbo = 0;
@@ -90,7 +86,7 @@ static int GL_minimized = 0;
static GLenum GL_read_format = GL_BGRA;
SDL_GLContext GL_context = NULL;
static std::unique_ptr<os::OpenGLContext> GL_context = nullptr;
void opengl_go_fullscreen()
{
@@ -98,7 +94,6 @@ void opengl_go_fullscreen()
return;
if ( (os_config_read_uint(NULL, NOX("Fullscreen"), 1) == 1) && (!os_get_window() || !(SDL_GetWindowFlags(os_get_window()) & SDL_WINDOW_FULLSCREEN)) ) {
os_suspend();
if(os_get_window())
{
SDL_SetWindowFullscreen(os_get_window(), SDL_WINDOW_FULLSCREEN);
@@ -119,7 +114,6 @@ void opengl_go_fullscreen()
os_set_window(window);
}
os_resume();
}
gr_opengl_set_gamma(FreeSpace_gamma);
@@ -135,7 +129,6 @@ void opengl_go_windowed()
return;
if (!os_get_window() || SDL_GetWindowFlags(os_get_window()) & SDL_WINDOW_FULLSCREEN) {
os_suspend();
if(os_get_window())
{
SDL_SetWindowFullscreen(os_get_window(), Cmdline_fullscreen_window ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0 );
@@ -150,8 +143,6 @@ void opengl_go_windowed()
}
os_set_window(new_window);
}
os_resume();
}
GL_windowed = 1;
@@ -169,14 +160,11 @@ void opengl_minimize()
if ( !(SDL_GetWindowFlags(os_get_window()) & SDL_WINDOW_FULLSCREEN) )
return;
os_suspend();
if (GL_original_gamma_ramp != NULL) {
SDL_SetWindowGammaRamp( os_get_window(), GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
}
SDL_MinimizeWindow(os_get_window());
os_resume();
GL_minimized = 1;
GL_windowed = 0;
@@ -227,7 +215,7 @@ void gr_opengl_flip()
if (Cmdline_gl_finish)
glFinish();
SDL_GL_SwapWindow(os_get_window());
GL_context->swapBuffers();
opengl_tcache_frame();
@@ -376,7 +364,7 @@ void gr_opengl_print_screen(const char *filename)
// now for the data
if (Use_PBOs) {
Assert( !pbo );
vglGenBuffersARB(1, &pbo);
glGenBuffers(1, &pbo);
if ( !pbo ) {
if (fout != NULL)
@@ -385,16 +373,16 @@ void gr_opengl_print_screen(const char *filename)
return;
}
vglBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pbo);
vglBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, (gr_screen.max_w * gr_screen.max_h * 4), NULL, GL_STATIC_READ);
glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
glBufferData(GL_PIXEL_PACK_BUFFER_ARB, (gr_screen.max_w * gr_screen.max_h * 4), NULL, GL_STATIC_READ);
glReadBuffer(GL_FRONT);
glReadPixels(0, 0, gr_screen.max_w, gr_screen.max_h, GL_read_format, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
// map the image data so that we can save it to file
pixels = (GLubyte*) vglMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY);
pixels = (GLubyte*) glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY);
} else {
pixels = (GLubyte*) vm_malloc_q(gr_screen.max_w * gr_screen.max_h * 4);
pixels = (GLubyte*) vm_malloc(gr_screen.max_w * gr_screen.max_h * 4, memory::quiet_alloc);
if (pixels == NULL) {
if (fout != NULL) {
@@ -436,10 +424,10 @@ void gr_opengl_print_screen(const char *filename)
}
if (pbo) {
vglUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);
pixels = NULL;
vglBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
vglDeleteBuffersARB(1, &pbo);
glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
glDeleteBuffers(1, &pbo);
}
// done!
@@ -450,7 +438,33 @@ void gr_opengl_print_screen(const char *filename)
}
}
void gr_opengl_cleanup(bool closing, int minimize)
void gr_opengl_shutdown(os::GraphicsOperations* graphicsOps)
{
graphics::paths::PathRenderer::shutdown();
opengl_tcache_shutdown();
opengl_light_shutdown();
opengl_tnl_shutdown();
opengl_scene_texture_shutdown();
opengl_post_process_shutdown();
opengl_shader_shutdown();
GL_initted = false;
if (GL_original_gamma_ramp != NULL) {
SDL_SetWindowGammaRamp( os_get_window(), GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
}
if (GL_original_gamma_ramp != NULL) {
vm_free(GL_original_gamma_ramp);
GL_original_gamma_ramp = NULL;
}
graphicsOps->makeOpenGLContextCurrent(nullptr);
GL_context = nullptr;
}
void gr_opengl_cleanup(os::GraphicsOperations* graphicsOps, bool closing, int minimize)
{
if ( !GL_initted ) {
return;
@@ -471,9 +485,7 @@ void gr_opengl_cleanup(bool closing, int minimize)
opengl_minimize();
if (minimize) {
}
gr_opengl_shutdown(graphicsOps);
}
void gr_opengl_fog_set(int fog_mode, int r, int g, int b, float fog_near, float fog_far)
@@ -496,9 +508,9 @@ void gr_opengl_fog_set(int fog_mode, int r, int g, int b, float fog_near, float
if (OGL_fogmode == 3) {
glFogf(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV);
glFogf(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH);
glFogf(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
} else {
glFogf(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH);
glFogf(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
}
GL_state.Fog(GL_TRUE);
@@ -718,7 +730,7 @@ void gr_opengl_set_gamma(float gamma)
// new way - but not while running FRED
if (!Fred_running && !Cmdline_no_set_gamma) {
gamma_ramp = (ushort*) vm_malloc_q( 3 * 256 * sizeof(ushort) );
gamma_ramp = (ushort*) vm_malloc( 3 * 256 * sizeof(ushort), memory::quiet_alloc);
if (gamma_ramp == NULL) {
Int3();
@@ -772,7 +784,7 @@ int gr_opengl_save_screen()
return -1;
}
GL_saved_screen = (ubyte*)vm_malloc_q( gr_screen.max_w * gr_screen.max_h * 4 );
GL_saved_screen = (ubyte*)vm_malloc( gr_screen.max_w * gr_screen.max_h * 4, memory::quiet_alloc);
if (!GL_saved_screen) {
mprintf(( "Couldn't get memory for saved screen!\n" ));
@@ -785,7 +797,7 @@ int gr_opengl_save_screen()
if ( Use_PBOs ) {
GLubyte *pixels = NULL;
vglGenBuffersARB(1, &GL_screen_pbo);
glGenBuffers(1, &GL_screen_pbo);
if (!GL_screen_pbo) {
if (GL_saved_screen) {
@@ -796,12 +808,12 @@ int gr_opengl_save_screen()
return -1;
}
vglBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_screen_pbo);
vglBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, gr_screen.max_w * gr_screen.max_h * 4, NULL, GL_STATIC_READ);
glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_screen_pbo);
glBufferData(GL_PIXEL_PACK_BUFFER_ARB, gr_screen.max_w * gr_screen.max_h * 4, NULL, GL_STATIC_READ);
glReadPixels(0, 0, gr_screen.max_w, gr_screen.max_h, GL_read_format, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
pixels = (GLubyte*)vglMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY);
pixels = (GLubyte*)glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY);
width_times_pixel = (gr_screen.max_w * 4);
@@ -814,15 +826,15 @@ int gr_opengl_save_screen()
sptr += width_times_pixel;
}
vglUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);
vglBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);
glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
vglDeleteBuffersARB(1, &GL_screen_pbo);
glDeleteBuffers(1, &GL_screen_pbo);
GL_screen_pbo = 0;
GL_saved_screen_id = bm_create(32, gr_screen.max_w, gr_screen.max_h, GL_saved_screen, 0);
} else {
opengl_screen_tmp = (ubyte*)vm_malloc_q( gr_screen.max_w * gr_screen.max_h * 4 );
opengl_screen_tmp = (ubyte*)vm_malloc( gr_screen.max_w * gr_screen.max_h * 4, memory::quiet_alloc);
if (!opengl_screen_tmp) {
if (GL_saved_screen) {
@@ -933,7 +945,7 @@ void gr_opengl_push_texture_matrix(int unit)
return;
glGetIntegerv(GL_MATRIX_MODE, &current_matrix);
vglActiveTextureARB(GL_TEXTURE0_ARB+unit);
glActiveTexture(GL_TEXTURE0+unit);
glMatrixMode(GL_TEXTURE);
glPushMatrix();
@@ -949,7 +961,7 @@ void gr_opengl_pop_texture_matrix(int unit)
return;
glGetIntegerv(GL_MATRIX_MODE, &current_matrix);
vglActiveTextureARB(GL_TEXTURE0_ARB+unit);
glActiveTexture(GL_TEXTURE0+unit);
glMatrixMode(GL_TEXTURE);
glPopMatrix();
@@ -967,7 +979,7 @@ void gr_opengl_translate_texture_matrix(int unit, const vec3d *shift)
}
glGetIntegerv(GL_MATRIX_MODE, &current_matrix);
vglActiveTextureARB(GL_TEXTURE0_ARB+unit);
glActiveTexture(GL_TEXTURE0+unit);
glMatrixMode(GL_TEXTURE);
glTranslated(shift->xyz.x, shift->xyz.y, shift->xyz.z);
@@ -979,6 +991,7 @@ void gr_opengl_translate_texture_matrix(int unit, const vec3d *shift)
void gr_opengl_set_line_width(float width)
{
GL_line_width = width;
glLineWidth(width);
}
@@ -1026,7 +1039,7 @@ void opengl_set_vsync(int status)
return;
}
SDL_GL_SetSwapInterval(status);
GL_context->setSwapInterval(status);
GL_CHECK_FOR_ERRORS("end of set_vsync()");
}
@@ -1049,47 +1062,11 @@ void opengl_setup_viewport()
glLoadIdentity();
}
// NOTE: This should only ever be called through os_cleanup(), or when switching video APIs
void gr_opengl_shutdown()
{
opengl_tcache_shutdown();
opengl_light_shutdown();
opengl_tnl_shutdown();
opengl_scene_texture_shutdown();
opengl_post_process_shutdown();
opengl_shader_shutdown();
GL_initted = false;
if (GL_original_gamma_ramp != NULL) {
SDL_SetWindowGammaRamp( os_get_window(), GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
}
if (GL_original_gamma_ramp != NULL) {
vm_free(GL_original_gamma_ramp);
GL_original_gamma_ramp = NULL;
}
SDL_GL_DeleteContext(GL_context);
GL_context = NULL;
}
// NOTE: This should only ever be called through atexit()!!!
void opengl_close()
{
// if ( !GL_initted )
// return;
}
int opengl_init_display_device()
int opengl_init_display_device(os::GraphicsOperations* graphicsOps)
{
int bpp = gr_screen.bits_per_pixel;
if ((bpp != 16) && (bpp != 32)) {
Int3();
return 1;
}
Assertion((bpp == 16) || (bpp == 32), "Invalid bits-per-pixel value %d!", bpp);
// screen format
switch (bpp) {
@@ -1181,7 +1158,7 @@ int opengl_init_display_device()
// allocate storage for original gamma settings
if ( !Cmdline_no_set_gamma && (GL_original_gamma_ramp == NULL) ) {
GL_original_gamma_ramp = (ushort*) vm_malloc_q( 3 * 256 * sizeof(ushort) );
GL_original_gamma_ramp = (ushort*) vm_malloc( 3 * 256 * sizeof(ushort), memory::quiet_alloc);
if (GL_original_gamma_ramp == NULL) {
mprintf((" Unable to allocate memory for gamma ramp! Disabling...\n"));
@@ -1194,73 +1171,33 @@ int opengl_init_display_device()
}
}
int r = 0, g = 0, b = 0, depth = 0, stencil = 1, db = 1;
os::OpenGLContextAttributes attrs;
attrs.red_size = Gr_red.bits;
attrs.green_size = Gr_green.bits;
attrs.blue_size = Gr_blue.bits;
attrs.alpha_size = (bpp == 32) ? Gr_alpha.bits : 0;
attrs.depth_size = (bpp == 32) ? 24 : 16;
attrs.stencil_size = (bpp == 32) ? 8 : 1;
mprintf((" Initializing SDL video...\n"));
attrs.multi_samples = os_config_read_uint(NULL, "OGL_AntiAliasSamples", 0);
#ifdef SCP_UNIX
// Slight hack to make Mesa advertise S3TC support without libtxc_dxtn
setenv("force_s3tc_enable", "true", 1);
attrs.major_version = 2;
attrs.minor_version = 0;
attrs.flags = os::OGL_NONE;
#ifndef NDEBUG
attrs.flags |= os::OGL_DEBUG;
#endif
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "Couldn't init SDL video: %s", SDL_GetError());
return 1;
}
attrs.profile = os::OpenGLProfile::Compatibility;
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, Gr_red.bits);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, Gr_green.bits);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, Gr_blue.bits);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, (bpp == 32) ? 24 : 16);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, (bpp == 32) ? 8 : 1);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, db);
int fsaa_samples = os_config_read_uint(NULL, "OGL_AntiAliasSamples", 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (fsaa_samples == 0) ? 0 : 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa_samples);
mprintf((" Requested SDL Video values = R: %d, G: %d, B: %d, depth: %d, stencil: %d, double-buffer: %d, FSAA: %d\n", Gr_red.bits, Gr_green.bits, Gr_blue.bits, (bpp == 32) ? 24 : 16, (bpp == 32) ? 8 : 1, db, fsaa_samples));
int windowflags = SDL_WINDOW_OPENGL;
if (Cmdline_fullscreen_window)
windowflags |= SDL_WINDOW_BORDERLESS;
// This code also gets called in the FRED initialization, that means we possibly already have a window!
if (os_get_window() == NULL)
{
uint display = os_config_read_uint("Video", "Display", 0);
SDL_Window* window = SDL_CreateWindow(Osreg_title, SDL_WINDOWPOS_CENTERED_DISPLAY(display), SDL_WINDOWPOS_CENTERED_DISPLAY(display),
gr_screen.max_w, gr_screen.max_h, windowflags);
if (window == NULL)
{
mprintf(("Could not create window: %s\n", SDL_GetError()));
return 1;
}
os_set_window(window);
}
GL_context = SDL_GL_CreateContext(os_get_window());
GL_context = graphicsOps->createOpenGLContext(attrs, (uint32_t) gr_screen.max_w, (uint32_t) gr_screen.max_h);
if (GL_context == nullptr) {
mprintf(("Error creating GL_context: %s\n", SDL_GetError()));
return 1;
}
SDL_GL_MakeCurrent(os_get_window(), GL_context);
//TODO: set up bpp settings
SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &r);
SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &g);
SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &b);
SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depth);
SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &db);
SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil);
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &fsaa_samples);
mprintf((" Actual SDL Video values = R: %d, G: %d, B: %d, depth: %d, stencil: %d, double-buffer: %d, FSAA: %d\n", r, g, b, depth, stencil, db, fsaa_samples));
graphicsOps->makeOpenGLContextCurrent(GL_context.get());
if (GL_original_gamma_ramp != NULL) {
SDL_GetWindowGammaRamp( os_get_window(), GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
@@ -1432,17 +1369,205 @@ void opengl_setup_function_pointers()
gr_screen.gf_set_team_color = gr_opengl_set_team_color;
}
#ifndef NDEBUG
static void debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const GLchar *message, const void *userParam) {
const char* sourceStr;
const char* typeStr;
const char* severityStr;
bool gr_opengl_init()
switch(source) {
case GL_DEBUG_SOURCE_API_ARB:
sourceStr = "OpenGL";
break;
case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB:
sourceStr = "WindowSys";
break;
case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB:
sourceStr = "Shader Compiler";
break;
case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:
sourceStr = "Third Party";
break;
case GL_DEBUG_SOURCE_APPLICATION_ARB:
sourceStr = "Application";
break;
case GL_DEBUG_SOURCE_OTHER_ARB:
sourceStr = "Other";
break;
default:
sourceStr = "Unknown";
break;
}
switch(type) {
case GL_DEBUG_TYPE_ERROR_ARB:
typeStr = "Error";
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
typeStr = "Deprecated behavior";
break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
typeStr = "Undefined behavior";
break;
case GL_DEBUG_TYPE_PORTABILITY_ARB:
typeStr = "Portability";
break;
case GL_DEBUG_TYPE_PERFORMANCE_ARB:
typeStr = "Performance";
break;
case GL_DEBUG_TYPE_OTHER_ARB:
typeStr = "Other";
break;
default:
typeStr = "Unknown";
break;
}
switch(severity) {
case GL_DEBUG_SEVERITY_HIGH_ARB:
severityStr = "High";
break;
case GL_DEBUG_SEVERITY_MEDIUM_ARB:
severityStr = "Medium";
break;
case GL_DEBUG_SEVERITY_LOW_ARB:
severityStr = "Low";
break;
default:
severityStr = "Unknown";
break;
}
nprintf(("OpenGL Debug", "OpenGL Debug: Source:%s\tType:%s\tID:%d\tSeverity:%s\tMessage:%s\n",
sourceStr, typeStr, id, severityStr, message));
}
static bool hasPendingDebugMessage() {
GLint numMsgs = 0;
glGetIntegerv(GL_DEBUG_LOGGED_MESSAGES_ARB, &numMsgs);
return numMsgs > 0;
}
static bool printNextDebugMessage() {
if (!hasPendingDebugMessage()) {
return false;
}
GLint msgLen = 0;
glGetIntegerv(GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB, &msgLen);
SCP_vector<GLchar> msg;
msg.resize(msgLen + 1); // Includes null character, needs to be removed later
GLenum source;
GLenum type;
GLenum severity;
GLuint id;
GLsizei length;
GLuint numFound = glGetDebugMessageLogARB(1, static_cast<GLsizei>(msg.size()), &source, &type, &id, &severity, &length, &msg[0]);
if (numFound < 1) {
return false;
}
debug_callback(source, type, id, severity, length, msg.data(), nullptr);
return true;
}
#endif
static void init_extensions() {
// if S3TC compression is found, then "GL_ARB_texture_compression" must be an extension
Use_compressed_textures = GLAD_GL_EXT_texture_compression_s3tc;
Texture_compression_available = true;
// Swifty put this in, but it's not doing anything. Once he uses it, he can uncomment it.
//int use_base_vertex = Is_Extension_Enabled(OGL_ARB_DRAW_ELEMENTS_BASE_VERTEX);
//allow VBOs to be used
if ( !Cmdline_novbo ) {
Use_VBOs = 1;
}
if ( !Cmdline_no_pbo && GLAD_GL_ARB_pixel_buffer_object ) {
Use_PBOs = 1;
}
// setup the best fog function found
if ( !Fred_running ) {
if ( GLAD_GL_EXT_fog_coord ) {
OGL_fogmode = 2;
} else {
OGL_fogmode = 1;
}
}
// if we can't do cubemaps then turn off Cmdline_env
if ( !GLAD_GL_ARB_texture_cube_map ) {
Cmdline_env = 0;
}
if ( !(GLAD_GL_ARB_geometry_shader4 && GLAD_GL_EXT_texture_array && GLAD_GL_ARB_draw_elements_base_vertex) ) {
Cmdline_shadow_quality = 0;
mprintf((" No hardware support for shadow mapping. Shadows will be disabled. \n"));
}
if ( !Cmdline_noglsl ) {
int ver = 0, major = 0, minor = 0;
const char *glsl_ver = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
sscanf(glsl_ver, "%d.%d", &major, &minor);
ver = (major * 100) + minor;
GLSL_version = ver;
// we require a minimum GLSL version
if (!is_minimum_GLSL_version()) {
mprintf((" OpenGL Shading Language version %s is not sufficient to use GLSL mode in FSO. Defaulting to fixed-function renderer.\n", glGetString(GL_SHADING_LANGUAGE_VERSION) ));
}
}
// can't have this stuff without GLSL support
if ( !is_minimum_GLSL_version() ) {
Cmdline_normal = 0;
Cmdline_height = 0;
Cmdline_postprocess = 0;
Cmdline_shadow_quality = 0;
Cmdline_no_deferred_lighting = 1;
}
if ( GLSL_version < 120 || !GLAD_GL_EXT_framebuffer_object || !GLAD_GL_ARB_texture_float ) {
mprintf((" No hardware support for deferred lighting. Deferred lighting will be disabled. \n"));
Cmdline_no_deferred_lighting = 1;
Cmdline_no_batching = true;
}
if (is_minimum_GLSL_version()) {
GLint max_texture_units;
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_units);
// we need enough texture slots for this stuff to work
if (max_texture_units < 6) {
mprintf(( "Not enough texture units for height map support. We need at least 6, we found %d.\n", max_texture_units ));
Cmdline_height = 0;
} else if (max_texture_units < 5) {
mprintf(( "Not enough texture units for height and normal map support. We need at least 5, we found %d.\n", max_texture_units ));
Cmdline_normal = 0;
Cmdline_height = 0;
} else if (max_texture_units < 4) {
mprintf(( "Not enough texture units found for GLSL support. We need at least 4, we found %d.\n", max_texture_units ));
GLSL_version = 0;
}
}
}
bool gr_opengl_init(os::GraphicsOperations* graphicsOps)
{
const char *ver;
int major = 0, minor = 0;
if ( !GL_initted )
atexit(opengl_close);
if (GL_initted) {
gr_opengl_cleanup(false);
gr_opengl_cleanup(graphicsOps, false);
GL_initted = false;
}
@@ -1451,38 +1576,55 @@ bool gr_opengl_init()
gr_screen.max_h,
gr_screen.bits_per_pixel ));
if ( opengl_init_display_device() ) {
if ( opengl_init_display_device(graphicsOps) ) {
Error(LOCATION, "Unable to initialize display device!\n");
}
// version check
opengl_check_for_errors("before glGetString(GL_VERSION) call");
ver = (const char *)glGetString(GL_VERSION);
opengl_check_for_errors("after glGetString(GL_VERSION) call");
Assertion(ver, "Failed to get glGetString(GL_VERSION)\n");
sscanf(ver, "%d.%d", &major, &minor);
// Initialize function pointers
if (!gladLoadGLLoader(GL_context->getLoaderFunction())) {
Error(LOCATION, "Failed to load OpenGL!");
}
GL_version = (major * 10) + minor;
// version check
GL_version = (GLVersion.major * 10) + GLVersion.minor;
if (GL_version < MIN_REQUIRED_GL_VERSION) {
Error(LOCATION, "Current GL Version of %d.%d is less than the "
"required version of %d.%d.\n"
"Switch video modes or update your drivers.",
major,
minor,
(MIN_REQUIRED_GL_VERSION / 10),
(MIN_REQUIRED_GL_VERSION % 10));
"required version of %d.%d.\n"
"Switch video modes or update your drivers.",
GLVersion.major,
GLVersion.minor,
(MIN_REQUIRED_GL_VERSION / 10),
(MIN_REQUIRED_GL_VERSION % 10));
}
GL_initted = true;
#ifndef NDEBUG
// Set up the debug extension if present
if (GLAD_GL_ARB_debug_output) {
nprintf(("OpenGL Debug", "Using OpenGL debug extension\n"));
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
GLuint unusedIds = 0;
glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, &unusedIds, true);
glDebugMessageCallbackARB((GLDEBUGPROCARB)debug_callback, nullptr);
// Now print all pending log messages
while (hasPendingDebugMessage()) {
printNextDebugMessage();
}
}
#endif
// this MUST be done before any other gr_opengl_* or
// opengl_* function calls!!
opengl_setup_function_pointers();
mprintf(( " OpenGL Vendor : %s\n", glGetString(GL_VENDOR) ));
mprintf(( " OpenGL Renderer : %s\n", glGetString(GL_RENDERER) ));
mprintf(( " OpenGL Version : %s\n", ver ));
mprintf(( " OpenGL Version : %s\n", glGetString(GL_VERSION) ));
mprintf(( "\n" ));
if (Cmdline_fullscreen_window || Cmdline_window) {
@@ -1491,9 +1633,7 @@ bool gr_opengl_init()
opengl_go_fullscreen();
}
// initialize the extensions and make sure we aren't missing something
// that we need
opengl_extensions_init();
init_extensions();
// setup the lighting stuff that will get used later
opengl_light_init();
@@ -1543,7 +1683,7 @@ bool gr_opengl_init()
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glHint(GL_FOG_HINT, GL_NICEST);
if ( Is_Extension_Enabled(OGL_ARB_SEAMLESS_CUBEMAP) ) {
if ( GLAD_GL_ARB_seamless_cube_map ) {
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
}
@@ -1575,7 +1715,7 @@ bool gr_opengl_init()
mprintf(( " Max elements indices: %i\n", GL_max_elements_indices ));
mprintf(( " Max texture size: %ix%i\n", GL_max_texture_width, GL_max_texture_height ));
if ( Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
if ( GLAD_GL_EXT_framebuffer_object ) {
mprintf(( " Max render buffer size: %ix%i\n",
GL_max_renderbuffer_size,
GL_max_renderbuffer_size ));
@@ -1590,6 +1730,9 @@ bool gr_opengl_init()
mprintf(( " OpenGL Shader Version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION) ));
}
mprintf(("Initializing path renderer...\n"));
graphics::paths::PathRenderer::init();
// This stops fred crashing if no textures are set
gr_screen.current_bitmap = -1;
@@ -1646,7 +1789,7 @@ DCF(ogl_anisotropy, "toggles anisotropic filtering")
return;
}
if ( !Is_Extension_Enabled(OGL_EXT_TEXTURE_FILTER_ANISOTROPIC) ) {
if ( !GLAD_GL_EXT_texture_filter_anisotropic ) {
dc_printf("Error: Anisotropic filter is not settable!\n");
return;
}
Loaded 100 of 438 files, more files were not shown because too many files have changed in this diff. Show more