In C++, globals initialization order accross translation units is not
defined. Accessing a global via a function ensures that it is initialized.
This will be needed for #7638, which will statically initialize change
handlers after the Options object has been initialized.
1. Moves more assets-related stuff from `init` to `engine/assets`.
2. Removes `SDL_audiolib` dependency from `soundsample.h`.
3. Cleans up some unused/missing includes.
Untangles dependencies by splitting up `engine.{h,cpp}` into 3 files:
1. `primitive_render`
2. `ticks` -- only contains `GetAnimationFrame` for now.
3. `GetWidth2` renamed to `CalculateSpriteTileCenterX` and moved to `levels/dun_tile.hpp`.
4 options args are a bit unwieldy, especially when you want
to pass only the first and the last one.
With a struct, there is no need to specify the default values
for the args in between.
Adds handy helpers for performing algorithms on the entire container.
They're prefixed with `c_` for container.
This naming convention is identical to some popular C++ libraries, such
as Abseil.
With fade 0 the cursor is never visible because everything is black.
While this is a very minor optimization, it works around
one of the instances of a bug in certain drivers as seen in #5618.
Done with the following script:
```ruby
Dir["Source/**/*.{h,c,cc,cpp,hpp}"].each do |path|
v = File.read(path)
next if !v.include?("uint32_t") || v.include?("cstdint")
lines = v.lines
line_num = if lines[2].start_with?(" *")
lines.index { |l| l.start_with?(" */") } + 3
else
3
end
lines.insert(line_num, "#include <cstdint>\n")
File.write(path, lines.join(""))
end
```
then fixed-up manually
A popup-like error dialog in selhero resulted in a heap-use-after-free:
https://gist.github.com/glebm/f014bd87f066d2b79965b7c48bd8f6d7
This is because the popup's `Deinit()` freed the background art.
The fix is simply to not free the background art.
This is OK because the popup never has a background.
It used to load an empty background in the past just to load the
palette but luckily it no longer does (otherwise this would require more
work).
Also, fixes dialog rendering:
1. Fixes what is rendered behind the dialog.
2. Draws the mouse (if possible) regardless of whether the background is
present.
3. Clears the screen if the background doesn't cover it completely.
Fixes#4195
https://github.com/diasurgical/devilutionx-mpq-tools produces an unpacked MPQ
with all the graphics converted to CLX and the unused files removed.
This is primarily useful on RAM-constrained platforms, such as PS2,
because it eliminates the MPQ overhead.
Adds a build option to load from such unpacked directories instead of the MPQ.
These directories are searched for in the same locations
where the MPQs would be searched for otherwise.
Example directory layout:
* /usr/local/share/diasurgical/devilutionx/diabdat/ -- unpacked and converted diabdat.mpq
* /usr/local/share/diasurgical/devilutionx/hellfire/ -- unpacked and converted hellfire MPQs (all of them merged into 1 directory)
* /usr/local/share/diasurgical/devilutionx/fonts/ -- unpacked fonts.mpq
* /usr/local/share/diasurgical/devilutionx/pl/ -- unpacked pl.mpq
These directory structure is produced by calling `unpack_and_minify_mpq`
* Difficulty indicator improvements
1. Clean up positioning code.
2. Do not show for non-save portraits.
3. Remove `vecDifficultyIndicators` - render the items on the fly instead
The format is almost identical to CL2, except it uses the frame header
to store frame width and height instead of 5 32-line offsets.
This means we always have access to frame dimensions, so we can use it
as an on-disk format for our graphics as well.
Additionally, we may be able to optimize the rendering even more
in the future now that we have guaranteed knowledge of frame dimensions.
Convert CEL files to CL2 at load time. CL2 format is more efficient and is about as fast to render.
CEL vs CL2 sizes, on dLvl 5: https://gist.github.com/glebm/9bbdd76962abcd4fd2405ecd3379af97
Memory:
* Peak memory (while loading): -300 KiB
* Memory in-game (dLvl5): -700 KiB
* RG99 binary size: -15 KiB (1333096 -> 1317192)
Performance on rg99:
* On average, -1 FPS in town.
* Same FPS in dungeon (20 FPS on dLvl 1).
* Change defines to constexpr int in player.h
* Add const or constexpr to player.h/cpp where applicable
* Update tests with changed names of player constatns
* remove unecessary variable
Diablo and Hellfire have different palettes in `ui_art\black.pcx`.
We now ship our own tiny `black.pcx` that takes priority over the
other ones. This `black.pcx` had the Diablo palette which resulted in an
incorrect palette in the Settings screen.
Split our own `black.pcx` file into `black_diablo.pcx` and
`black_hellfire.pcx` and load the correct one depending on the mode.
1. There is no small logo. Simply use 2 variables.
2. The medium logo is much smaller as PCX:
* Hellfire (`ui_art\hf_logo2.pcx`): 1591816 bytes -> 195850 bytes
* Diablo (`ui_art\smlogo.pcx`): 341923 bytes -> 333099 bytes
* Move `ArtLogoBig` to `title.cpp`
It is only ever used there
* Add MakeRectangle helper to convert from SDL_Rect
* Add Rectangle::inset method for shrinking a rectangle
Turns out some of the other use cases I though this could apply to were actually doing something based on a fixed region
* Simplify initialisation of settings menu rects