Commit graph

250 commits

Author SHA1 Message Date
Gleb Mazovetskiy
b7beb2fbe9 Optimize DrawHalfTransparentBlendedRectTo
`DrawHalfTransparentBlendedRectTo` takes up a significant chunk of time
when rendering store and quest dialogs.

Optimize the function to read 2 pixels at a time and write 4 pixels at a
time.
2021-11-07 19:18:49 +00: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
90960f0c14 Remove dead code 2021-08-07 00:36:38 +02:00
Anders Jenbo
35ccc8eb1c Apply clang-tidy to code 2021-07-10 17:30:15 -07:00
Anders Jenbo
74b57558c9 🚚 Move local code to anonymous namespace 2021-07-10 17:30:15 -07:00
ephphatha
b680e3fef1 Align end comment markers for doxygen comments
Including a bunch from previous PRs (since I was responsible for the broken formatting for most 😓)
2021-07-09 18:00:15 +02:00
Gleb Mazovetskiy
cb0dae8590 🚚 Rename CelOutputBuf to Surface and extract 2021-07-03 05:33:32 -07:00
ephphatha
357f6f1dc3 Move RNG functions to their own header/source files 2021-06-27 03:09:41 -07:00
Andrew James
20190ee687
Update random number functions to avoid IB (#2226)
* Update random number functions to avoid IB

Most calls to set seed were using uint32_t already, there were a few variables which were better served by having their type changed from signed to unsigned. The one exception is ItemStruct::_iSeed. This is an identifier that also happens to be used as a seed occasionally so a comment was added documenting this exception.

Includes suggested style changes for Source/towners.h; Source/towners.cpp; Source/msg.h; Source/multi.h
2021-06-27 10:37:09 +02:00
Gleb Mazovetskiy
e40b1963f9 🚚 engine.h: Extract CelSprite and file loading 2021-06-21 01:36:20 -07:00
ephphatha
8d5b5e833b Add tests for LCG random engine
This documents the chosen LCG parameters and the default mapping function used in random number generation.

GetLCGEngineState() is a helper needed for testing because AdvanceRndSeed combines a distribution with a call to progress the engine. I'll split those eventually but this at least shows the current behaviour and should flag any bugs introduced by future changes.
2021-06-20 16:27:06 -07:00
ephphatha
fa8eada221 Remove unused variable.
It was documented as if this stored a seed in the previous LCG cycle but it actually stored the initial seed for the current cycle. This value is never used.
2021-06-20 02:51:04 -07:00
Gleb Mazovetskiy
f9d20b44d6 🎉 Hardware cursor (SDL2-only)
Disabled by default because of these known issues:

1. When clicking on inventory item, it briefly appears a bit shifted (in the wrong coordinates).

   This issue can happen with software cursor as well, but is a lot more
   obvious with the hardware cursor.

2. Cursor is scaled with nearest-neighbour scaling, which may look a bit different from
   how the rest of the graphics are scaled.

See also previous attempt: https://github.com/diasurgical/devilutionX/pull/955 by @viciious

Co-authored-by: Victor Luchits <vluchits@gmail.com>
2021-06-19 01:03:40 +02:00
Gleb Mazovetskiy
982260d94e Clip control.cpp draw calls
No longer crashes there when running at a resolution smaller than
640x480
2021-06-16 03:12:54 +02:00
qndel
b1d74d2791
alt highlighting (#2060) 2021-05-25 23:47:29 +02:00
obligaron
60616f2497 LoadFile support in Unittests 2021-05-24 20:12:43 +02:00
Juliano Leal Goncalves
d55cd99dd5 🚚 Rename 'direction' enum to 'Direction' 2021-05-24 04:46:08 +02:00
Anders Jenbo
a095bc0bf7 ♻️Migrate more code away from miniwin 2021-05-13 02:30:18 +02:00
staphen
3e5e5b2696 Synchronize SFileCloseFile() access 2021-05-08 04:01:07 +02:00
Gleb Mazovetskiy
9a9941efdd 🚚 Move CL2 rendering to engine/render/cl2_render.cpp 2021-05-07 01:02:03 +02:00
Gleb Mazovetskiy
0edfa3de66 🚚 Move CEL rendering to engine/render/cel_render.cpp 2021-05-07 00:16:40 +02:00
Gleb Mazovetskiy
473d1b0b14 🎉 Clip CEL drawing functions
Implements clipping for all CEL drawing functions except stippled and outline.
2021-05-07 00:16:40 +02:00
Anders Jenbo
f579b2f287 Handle cel/cl2 files as byte arrays 2021-05-06 13:17:54 +02:00
Gleb Mazovetskiy
e7a9293153 ♻️ engine.h: Minor refactoring
1. Move `SetPixel` definition to the header to make it easier for the
   compiler to inline (make it inlinable even without LTO).
2. Add an `operator[](Point)` overload to `CelOutputBuffer`.
2021-05-06 12:58:06 +02:00
Gleb Mazovetskiy
afef72f916 🎉 New map renderer
Uses integer math only: This speeds up the rendering and eliminates some
zoom artifacts.

Improves player indicator look -- it's now symmetric and more legible.
2021-05-06 12:58:06 +02:00
Anders Jenbo
92db72719d 🔥 Remove some unused code 2021-05-05 10:16:45 +02:00
Anders Jenbo
3746723f52 ♻️Add type to MIN-files and TRN-files 2021-05-05 04:03:23 +02:00
Anders Jenbo
fa0b286693 ♻️Typed file loading
Tthis gives us the option to specify what type a file should be loaded
as, avoidng the need to case it and does some automatic checks on the
fitness of the data, while making the process simpler.

If no type is given then the type will be set to std::byte which limit
what operations can be performed on the data.
2021-05-04 19:08:37 +02:00
Gleb Mazovetskiy
987ab2533b 🐞 Synchronize SFileReadFile access
StormLib read function is not thread-safe: https://github.com/ladislav-zezula/StormLib/issues/175
2021-05-03 02:35:22 +02:00
Anders Jenbo
654a2b8834 ♻️Clean up automap code
Use Point for x,y pairs. Make helpers for drawing door and squares
2021-05-02 15:27:38 +02:00
Gleb Mazovetskiy
f33f7ae7eb 💨 Do not zero-initalize arrays we write to
`std::make_unique<T[]>(size)` always zero-initalizes the array.

C++20 has `std::make_unique_for_overwrite` to avoid that, while
older C++ versions can use the approach applied here.
2021-05-02 05:52:11 +02:00
Gleb Mazovetskiy
63e0e60956 Add MeasureSolidHorizontalBounds
Adds a function to measure the X-coordinates of the solid
(non-transparent) bounding box of a CEL.
2021-05-02 00:22:07 +02:00
Gleb Mazovetskiy
1b8b62a8c2 ♻️ Store CEL width with the sprite itself
Instead of passing the CEL sprite width when drawing, store the CEL
width at load time in the new `CelSprite` struct.

Implemented for most sprites except towners, missiles, or monsters.
2021-05-01 20:51:55 +02:00
Gleb Mazovetskiy
144dd6cd93 ♻️ engine.cpp: Minor cleanup in draw functions
1. Introduce a couple of constants.
2. Extract a helper function for getting the light table pointer.
2021-04-28 11:53:39 +01:00
thebigMuh
ad8f342db0 Adding constness 2021-04-26 23:30:02 +02:00
obligaron
239a43cc1c
Remove "AnimWidth2" expect for missiles (#1680) 2021-04-25 13:32:33 +02:00
Anders Jenbo
f77c52941a ♻️Make GetDirection take Points instead of ints 2021-04-25 02:25:52 +02:00
Anders Jenbo
bd389e9ef6 ♻️ Clean up bool logic in engine.cpp 2021-04-23 02:47:10 +02:00
Anders Jenbo
1e3ed903be 🎨 strip redundant else 2021-04-22 00:39:48 +02:00
Anders Jenbo
593c6a6f17 🎨 Drop unused param and rename random_ to GenerateRnd 2021-04-22 00:08:19 +02:00
Anders Jenbo
d024f79b0e 🧹 performance-unnecessary-value-param 2021-04-22 00:08:19 +02:00
Jmgr
1d84156509 Simplify bitshift divisions/multiplications 2021-04-21 05:31:17 +02:00
Anders Jenbo
bb4e1960e7 🎨 modernize-use-nullptr 2021-04-19 16:02:05 +02:00
Anders Jenbo
c89bd9c001 🚨 Fix remaning warnings for clang and gcc 2021-04-19 02:44:39 +02:00
Anders Jenbo
997c1dba55 🚚 Split up all.h in to proper header relations 2021-04-16 01:04:54 +02:00
Anders Jenbo
6e1a106a38 🚚 Move header we implement into the project 2021-04-16 01:04:54 +02:00
Gleb Mazovetskiy
26a9930a70 Stop relying on buffer padding in CelBlitSafeTo 2021-04-10 19:09:28 +01:00
Anders Jenbo
20186e0370 🎨 Replace TRUE/FALSE with true/false
fix


Fix


fix
2021-04-09 15:13:02 +02:00
Anders Jenbo
93d42b62b8 ♻️ Change BOOL to bool 2021-04-09 15:13:02 +02:00
Anders Jenbo
bfb3c11c2b 🎨 Change namespace to devilution 2021-04-06 15:21:25 +02:00