Commit graph

225 commits

Author SHA1 Message Date
Kp f9ed412ba6 Move use of SQUARE into a helper
Give the compiler discretion over whether to inline the multiplications.
2021-08-26 03:13:45 +00:00
Kp 172c183d83 Reduce scope of font rendering variables 2021-08-26 03:13:45 +00:00
Kp 517919a473 Remove unused return value of gr_internal_color_string, ogl_internal_string 2021-08-26 03:13:45 +00:00
Kp 1c13d3c8d3 Improve error reporting for PHYSFSX_openReadBuffered
Return the PHYSFS error code on failure, so that callers can report why
the open failed.
2021-07-25 23:00:56 +00:00
Kp a7cbf60922 Return error code from PHYSFSRWOPS_openRead*
This improves error reporting for movies.
2021-07-25 23:00:56 +00:00
Kp ee07a45712 Simplify MALLOC invocations
Remove overload for C array decay, and fix up the call sites that
required it.
2021-06-28 03:37:48 +00:00
Dmitry Grigoryev fbd05a1592 optimize include files (include what you use) 2021-02-06 21:38:50 +01:00
Kp 081024eb8f Fix build for screenshot=legacy opengl=0
Reported-by: dimag0g <https://github.com/dxx-rebirth/dxx-rebirth/pull/568>
2021-02-06 17:53:53 +00:00
Kp c0601edde3 Move GammaLevel to CCfg 2020-12-27 22:03:09 +00:00
Kp aaf4629c05 Fix potential canvas.cv_font / cv_font inconsistency in gr_ustring
A prior conversion changed the actual rendering to use the argument
cv_font, but still picked which render function to use based on the
flags for the active font.  Switch to use only the supplied font.
2020-12-27 22:03:09 +00:00
Kp c1d6150015 Pass grs_font& to gr_set_curfont 2020-12-27 22:03:09 +00:00
Kp 2ded2b2d0c Make kmatrix background optional
Previously, if the background failed to load, the kmatrix window was
immediately aborted.  Change the logic so that a failure to load uses a
blank black background, but still shows the kmatrix window.
2020-12-26 21:17:29 +00:00
Kp fc63029833 Move more symbols into namespaces 2020-12-26 21:17:29 +00:00
Kp 017c4ce933 Restore buffering on PCX loads
Commit 3114874713 delegated PCX loading to
SDL_image, and as an incidental change, switched to using an unbuffered
PHYSFS file.  On Linux, this has no perceptible difference in
performance.  On Windows, the unbuffered accesses cause enough of a
performance problem for users to notice and report an issue.  Add a new
helper to create an SDL_RWops around a buffered file, and use that for
PCX loading.

Fixes: 3114874713 ("Delegate PCX loading to SDL_image")
Reported-by: Q3BFG10K <https://github.com/dxx-rebirth/dxx-rebirth/issues/549>
Reported-by: aybe <https://github.com/dxx-rebirth/dxx-rebirth/issues/555>
Analyzed-by: arbruijn <https://github.com/dxx-rebirth/dxx-rebirth/issues/555#issuecomment-735442076>
2020-11-30 05:12:00 +00:00
Kp 6285878c4c Add color_palette_index type alias, to note palette-related uint8_t 2020-07-16 02:31:04 +00:00
Kp 80f8bbabd1 Add constexpr to compile-time switches in font templates 2020-07-16 02:31:04 +00:00
Kp 8cc7be4986 Use std::bitset to track used colors
This reduces memory usage over using std::array<bool> for the same
number of bits.
2020-07-16 02:31:04 +00:00
Kp 316a4740a6 Move words_bigendian into if constexpr
`words_bigendian` is `constexpr`, so move the tests on it behind `if
constexpr` to encourage the compiler to prune unreachable paths.
2020-07-05 23:34:33 +00:00
Kp 6e4b63e098 Use C++17 std::size instead of custom lengthof
lengthof was added to provide the size of C arrays.  C++17 std::size is
now available, and can serve the same purpose.  Remove the custom
lengthof.

The generated code is the same in both cases, other than the change in
line numbers caused by removal of the #include directives.
2020-07-05 23:34:32 +00:00
Kp 7a790f6068 Inline gr_set_fontcolor
It is a trivial function.
2020-07-05 23:34:32 +00:00
Kp f413017317 Delegate bald_guy_load PCX to SDL image 2020-05-17 23:35:26 +00:00
Kp 83a9b32dc7 Simplify bald_guy_load
Close the file sooner.  Use std::transform with a reverse_iterator to
decode and transpose the blob.
2020-05-17 23:35:26 +00:00
Kp 3114874713 Delegate PCX loading to SDL_image
This adds a new dependency, but most systems likely already have
SDL_image installed.  Use of SDL_image can be disabled, but this is
discouraged, because various in-game interfaces assume the use of the
original background.

The old implementation automatically corrected for filename case.  The
new implementation expects that the supplied filename can be passed to
PYHSFS_openRead as-is.  All known uses in-game have been corrected to
satisfy this requirement.  If the new stricter match requirement becomes
a problem, a variant of PHYSFSRWOPS_openRead that adjusts filename case
could be created for use here.

- Update install instructions
- Update ebuild
- Update Arch PKGBUILD
2020-05-17 23:35:26 +00:00
Kp db7b4b3f88 Refer to <memory> directly, not through "compiler-make_unique.h" 2020-05-02 21:18:43 +00:00
Kp cc38cdf4b8 Qualify uses of std::make_unique 2020-05-02 21:18:42 +00:00
Kp 8839f538e0 Refer to <array> directly, not through "compiler-array.h" 2020-05-02 21:18:42 +00:00
Kp 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
Kp b4d974e5b2 Remove register; it has no effect, and will be deprecated in C++17 2020-05-02 21:18:42 +00:00
Kp d197ba42c3 Fix mouse-selection in listboxes
Commit d355ef4030 removed a seemingly unnecessary modification of the
global variable grd_curcanv->cv_font, after eliminating all local reads
of it.  However, a non-local read, buried in listbox_mouse, depended on
grd_curcanv->cv_font being set to a MEDIUM font.  After that commit,
grd_curcanv->cv_font retained its prior value, which is not a MEDIUM
font.  This caused listbox_mouse to compute an incorrect height of the
lines in the listbox, which manifested as the game choosing the wrong
line when the mouse is clicked in the listbox.

Fix the problem by explicitly using MEDIUM3_FONT, since that was
usually the value left in grd_curcanv->cv_font prior to that commit.  In
some cases, a different MEDIUM font would be left there, but all the
MEDIUM fonts have the same height, so they are interchangeable for this
purpose.

Reported-by: Q3BFG10K <https://github.com/dxx-rebirth/dxx-rebirth/issues/498>
Fixes: d355ef4030 ("Pass font to various drawing functions")
2020-04-04 19:30:23 +00:00
Kp 597cb41717 Downgrade PCX failures from Error to CON_URGENT
There is no need to kill the program due to a missing or malformed PCX file.
2019-07-07 22:00:02 +00:00
Kp 3a0cca001f Limit size of PCX files 2019-07-07 22:00:02 +00:00
Kp 9bed4f6d78 Fix bogus borders due to fill_n length/value transposition
Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/issues/415>
Fixes: 7bcbaae230 ("Tighten protection against grs_bitmap bm_data confusion")
2019-03-29 02:34:53 +00:00
Kp 7bcbaae230 Tighten protection against grs_bitmap bm_data confusion
Bitmaps based on grs_main_bitmap own their data.  Bitmaps based on
grs_bitmap do not.  Adjust prototypes to prevent initializing a
grs_main_bitmap with data it will not own.
2019-02-02 18:36:39 +00:00
Kp 60a99f1ea2 Allow longer mission titles in New Game dialog 2018-06-27 03:34:34 +00:00
Kp d5bfeb0813 Fix OS X build break
Github user bdamm (Rebirth forum user dammfine) reports[1][2][3] a build
failure on OS X, likely caused by clang failing to implement forwarding
constructors fully.  The Rebirth fallback to variadic constructor
forwarding is imperfect, and in this case caused a failure.  Add an
explicit conversion to disambiguate the ternary expression's type.

[1]: Rebirth forum report: https://forum.dxx-rebirth.com/showthread.php?tid=1055
[2]: Github commit comment: ccc2a288f1?diff=unified#commitcomment-29322121
[3]: Github issue: https://github.com/dxx-rebirth/dxx-rebirth/issues/391

Reported-by: bdamm <https://github.com/dxx-rebirth/dxx-rebirth/issues/391>
Fixes: ccc2a288f1 ("Simplify HUD_SCALE_X_AR, HUD_SCALE_Y_AR")
2018-06-12 02:53:06 +00:00
Kp f51b7b6b20 Enforce separation of font X/Y scaling 2018-06-08 04:04:05 +00:00
Kp 08446f0ab6 Pass font to gr_string,gr_printf 2018-05-19 23:21:42 +00:00
Kp a19d4157e2 Prevent reloading cv_font in font.cpp internal functions
Callers usually have cv_font already loaded, so pass it down instead of
reloading from memory.
2018-05-19 23:21:42 +00:00
Kp ca2b1e0cf0 Remove build_colormap_good parameter used
`build_colormap_good` only took `used` to clear it.  Only one caller
needed it cleared.  Move the clear into that caller.  Remove the
parameter from all calls.
2018-03-08 04:21:18 +00:00
Kp b6e2205b9f Simplify palette color tracking
Callers only care whether a color is used, not how often it is used.
2018-03-08 04:21:18 +00:00
Kp 131c1b9f4d Add support for PNG screenshots 2018-02-18 00:42:42 +00:00
Kp 88832e3679 Use constexpr integral_constant for various magic numbers 2017-10-14 17:10:30 +00:00
Kp 719de35484 Pass grs_bitmap to gr_pixel 2017-03-11 19:56:23 +00:00
Kp 5541e764cd Use cached canvas in font.cpp 2017-03-11 19:56:23 +00:00
Kp c725a6cb88 Pass canvas to gr_init_font 2017-03-11 19:56:22 +00:00
Kp b390ce2da0 Use cached canvas in gr_string 2017-02-11 21:42:46 +00:00
Kp 05905ced06 Pass font to gr_get_string_wrap 2017-02-11 21:42:44 +00:00
Kp 46be18e7f9 Pass canvas to get_centered_x 2017-02-11 21:42:44 +00:00
Kp 6f81d13c41 Pass canvas to gr_set_curfont 2017-02-11 21:42:38 +00:00
Kp ae33aaafc1 Pass canvas to gr_set_fontcolor 2017-02-11 21:42:32 +00:00