This allows forcing the locale without changing the settings.
The `forceLocale` option also lets us avoid changing the locale in settings if fonts.mpq is missing, fixing the following scenario:
1. System locale is ja
2. Launch the game -- fonts are missing
3. Close the game, download fonts.mpq
4. Launch the game again -- it is now in English because the settings have changed
When using `UNPACKED_MPQS`, avoid all the SDL machinery for reading
files.
This is beneficial not only due to reduced indirection but also because
we can test for the file's existence and get the file size without
opening it, which is much faster.
When rendering directly to the output buffer, we need to maintain the
state of what has been drawn and what needs redrawing per-buffer.
We previously tried to do it implicitly by checking `SDL_DOUBLEBUF` and
other flags. The previous implementation was broken in several
ways, resulting in rendering issues on devices that support 8-bit output
directly.
Changes this mechanism to explicitly maintain buffer state per output
buffer. The new mechanism doesn't require knowledge of the number of
buffers, and thus also works correctly with triple-buffering.
Fixes#5447
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`
1. Do not modify the map after loading. Instead, return string views
(guaranteed to be null-terminated) from look up functions and return
the key directly if not found.
2. Use an `unorded_map` instead of `map` where available (C++20).
Saves a bit of RAM (~50 KiB) and improves lookup performance.
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.