Commit graph

155 commits

Author SHA1 Message Date
Gleb Mazovetskiy
e1dc7df3a5 Fix crash in WordWrapString
Fixes #3433
2021-11-07 23:21:21 +01:00
Gleb Mazovetskiy
8e5bc0597a Don't line-break in the middle of a punct sequence
Also removes a redundant copy of the input string.

Fixes #3420
2021-11-07 19:03:35 +00:00
Gleb Mazovetskiy
e9a9daa794 DrawString: Stop allocating
Switch to a state-machine UTF-8 decoder from the branchless one.
This allows us to avoid copying the string on every `DrawString` call.
2021-11-07 04:17:50 +01:00
Gleb Mazovetskiy
3d308983a8 Migrate to libmpq
libmpq is a much simpler alternative to StormLib for reading MPQ archives.

We use our own fork of libmpq: https://github.com/diasurgical/libmpq

Impact:

* DevilutionX is now a lot more portable. Unlike StormLib, libmpq only
  needs platform-specific code for Windows.
* Locks around file access **removed** (instead we duplicate the file descriptor for streamed audio only).
* RAM usage is **300 KiB** lower than StormLib.
* Stripped release linux_x86_64 binary is **32 KiB** smaller.
* Amiga build now hangs instead of crashing.
2021-11-06 23:51:42 +00:00
Gleb Mazovetskiy
117695489b
DrawArt: Fix bounds check (#3395)
The bounds checks were performed against the global screen dimensions
instead of the output buffer dimensions.

Also includes some minor cleanup of DrawArt.

Fixes #3388
2021-11-05 14:17:56 +00:00
qndel
5a35e0640b shorter & better MeasureSolidHorizontalBounds 2021-11-02 14:10:44 +01:00
Anders Jenbo
9cee65da6c Correct calculation for KerningFitSpacing 2021-10-24 16:28:28 +02:00
Anders Jenbo
b227afc4c4 Do not render text past first encoding error
Continuing past the error allows for CTD attacks using special crafted
invalid UTF-8 with a multiby indicator at the end the string
2021-10-24 16:28:28 +02:00
Anders Jenbo
11e37e972a Port essential parts to use SDL abstraction for file access 2021-10-20 21:52:59 +02:00
Gleb Mazovetskiy
dec45920eb Text rendering: Support Zero-width space
Zero-width space is a non-printing character that indicates a word
boundary.

https://en.wikipedia.org/wiki/Zero-width_space
2021-10-20 02:33:25 +02:00
Anders Jenbo
5b3abbd315 Correct dialog font full width 2021-10-17 08:40:45 +02:00
Anders Jenbo
b3546e3254
Load full width kerning programmatically 2021-10-16 02:00:30 +02:00
Anders Jenbo
f022a341b0 Avoid crashing from missing fonts 2021-10-12 21:05:19 +02:00
Andrew James
949206424e
Enable clang-tidy in Visual Studio projects (#3101) 2021-10-12 00:32:57 +00:00
ephphatha
b15e08fc3f Deduplicate logic in GetAnimationProgress 2021-10-11 18:59:02 +02:00
obligaron
f7efb72314 Fix LoadFileInMem std::array overload 2021-10-10 00:51:45 +02:00
Gleb Mazovetskiy
f4404e1452 WordWrapString: Also break on U+FF0C (FULLWIDTH COMMA) 2021-10-01 10:29:03 +02:00
Gleb Mazovetskiy
ff9affa513 Fix a couple of noisy MSVC warnings 2021-09-30 18:16:31 +02:00
Gleb Mazovetskiy
0c694edaba WordWrapString: Wrap on punctuation
Useful for Chinese and Japanese, which do not have spaces between words,
nor whitespace after punctuation.
2021-09-30 18:16:31 +02:00
Anders Jenbo
4dd8b121ec Replace TTF with PCX font 2021-09-29 18:13:48 +02:00
Anders Jenbo
d0f70d5468 Correct loading of unicode fonts past row 09 2021-09-25 03:59:00 +02:00
Anders Jenbo
704a04ae4d Add support for Unicode fonts 2021-09-24 03:03:58 +02:00
Alex
6df826eb02 Fix compiler warnings 2021-09-23 19:06:37 +02:00
Anders Jenbo
7771a08d03 Translatable mainpanel 2021-09-19 07:21:52 +02:00
Gleb Mazovetskiy
4e1ad7ab65 LoadFile: Avoid opening the file twice
Previously we were passing the path to `GetFileSize`, which resulted in
opening and closing the file twice.
2021-09-18 06:44:48 +02:00
staphen
fb4f1ed8fd Add structs for virtual gamepad 2021-09-16 19:25:31 +02:00
obligaron
e67ea3639f Fix AnimationInfo::GetAnimationProgress() when normal animation logic is used (for example loaded save games) 2021-09-16 19:22:24 +02:00
staphen
09b8afba4e Fix OOB error in DrawString 2021-09-13 23:48:54 +02:00
qndel
1f61b683a6 fix chat line wrapping 2021-09-13 22:53:32 +02:00
Juliano Leal Goncalves
5607c58daa 🏷️ Add 'PickRandomlyAmong' function that picks one value from a set of values randomly
This will be used in a few places where we previously used a raw integer random to index into a local array for selection, simplifying that type of logic to a single statement.
2021-09-13 00:25:49 +02:00
ephphatha
67ecea1a42 Always set the monster animation when ChangeAnimationData is called
Required updating AnimationInfo to handle being passed 0 for the total framecount, previously it would call clamp with min > max which was invalid.
2021-09-12 02:27:47 +02:00
ephphatha
8e155e011f Rename helpers on Monster to match AnimationInfo 2021-09-12 02:27:47 +02:00
ephphatha
b12de6fe12 Use scoped enum for Direction
Identified and removed an instance of Direction being used as an argument for a bool parameter

Removed a single-use temporary variable being cast from sprite frame to direction to size_t

Co-authored-by: Anders Jenbo <anders@jenbo.dk>

Fix alignment of WalkSettings array
2021-09-12 02:27:47 +02:00
Anders Jenbo
41f6b62caa Fix infinit loop if first word overflows the text box
Fixes #2829
2021-09-12 01:37:28 +02:00
Anders Jenbo
7169882b1f Implement new font rendering 2021-09-12 01:37:28 +02:00
Juliano Leal Goncalves
5bb7b0bf23 ♻️ Reduce visibility of 'Displacement::fromDirection' to 'private'
This will enforce the new constructor conversion approach over the use of the static method.
2021-09-06 12:57:59 +02:00
Juliano Leal Goncalves
32e22a16b3 ♻️ Leverage conversion constructor for 'Direction' to 'Displacement'
This makes code more consistent overall as we use the same pattern for dealing with Sizes.
2021-09-06 12:57:59 +02:00
Juliano Leal Goncalves
244235d1de 🏷️ Add explicit conversion constructor on 'Displacement' from 'Direction'
We'll leverage this for consistency with other conversions which similarly use a conversion constructor instead of a static method like 'fromDirection'.
2021-09-06 12:57:59 +02:00
Juliano Leal Goncalves
7da37da8c9 ♻️ Leverage 'Point' in 'RenderTile' function 2021-09-06 00:31:25 +02:00
Juliano Leal Goncalves
bb2dfdfb73 🚚 Rename 'ItemStruct' to 'Item' 2021-08-30 13:40:08 +02:00
Juliano Leal Goncalves
f90d3239e5 Add 'Center()' method on 'Rectangle' 2021-08-30 06:45:51 +02:00
Juliano Leal Goncalves
222817af23 Add divide by int operator to 'Size' struct
To be used in several places for finding the "center" of rectangles, for example
2021-08-30 06:45:51 +02:00
obligaron
02900c8fa5 Demo: Fix rendering jittering 2021-08-29 21:40:24 +02:00
obligaron
2a6e5712de Disable hardware cursor for demo playback 2021-08-29 10:26:50 +02:00
Anders Jenbo
df636c0afc Remove DIR_OMNI 2021-08-23 10:51:06 +02:00
Vladimir Olteanu
090a04670c Make OwnedSurface::OwnedSurface(Size) explicit 2021-08-20 15:15:40 +01:00
Vladimir Olteanu
bfcc57783c Remove Surface::{Alloc,Free}, introduce OwnedSurface 2021-08-19 08:51:59 +02:00
obligaron
26e61b363b demo: Centralize options override 2021-08-19 00:04:57 +02:00
obligaron
77f9bded9e Introduce demo namespace 2021-08-19 00:03:58 +02:00
Vladimir Olteanu
b17ff04ee2 Use string_view in DrawString and friends 2021-08-05 01:40:43 +02:00