702 Commits
Author SHA1 Message Date
Gleb MazovetskiyandClaude Sonnet 5 b0a3b7babb Migrate AnimationInfo's internal fixed-point fields to FixedPoint
Add FixedPoint::divideWithoutWidening for cases where the caller can
already show the wide intermediate isn't needed, and use it in
AnimationInfo::setNewAnimation to avoid a 64-bit division that the
original int32_t arithmetic never required.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-10-11 21:55:08 +01:00
Gleb MazovetskiyandClaude Sonnet 5 92927ca913 Migrate ClassAttributes, player HP/mana, item HP/mana bonuses, and monster HP to Fixed10_6/Fixed26_6
Replaces ParseFixed6/parseFixed6/readFixed6/readDecimal's raw-int
plumbing with the new FixedPoint type, then propagates strongly-typed
fixed-point fields through everywhere that consumed them: player
_pHitPoints/_pMana (and their base/max variants), ClassAttributes'
percentage/multiplier fields, Item::_iPLHP/_iPLMana, and
Monster::hitPoints/maxHitPoints. Eliminates manual <<6/>>6 bit-shifting
at nearly every call site in favor of fromInt/fromRaw/whole() and the
new fixed-point arithmetic operators, while preserving raw() only at
genuine serialization/network wire-format boundaries.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-10-11 21:55:08 +01:00
Developer Guilliman a461a18275 Golem monster portrait (#8729)
Added option to show summoned monster (Golem) party portrait
Fixed crash when loading .trn files for monsters with missing animations
(Golem is missing standing animation)
2026-10-10 19:20:43 +01:00
Anders Jenbo e00b7260ff Prevent inlining of blitter operations 2026-09-15 05:32:22 +02:00
Anders Jenbo c90181d54b Fix directy rect blitting 2026-09-15 05:32:22 +02:00
Anders Jenbo 3f71a5b8c0 Yield for audio thread on systems with cooperative threading 2026-09-15 05:32:22 +02:00
Gleb MazovetskiyandClaude Sonnet 4.6 53b91fd7a2 Untangle more dependencies
Split several monolithic files to reduce transitive dependencies and
enable the dun_render_benchmark to link without bringing in all of
DevilutionX:

- Extract dungeon tile globals and loading functions from `gendung` into
  `dun_tile_data.{hpp,cpp}`
- Extract light table data and MakeLightTable from lighting into
  `engine/light_tables.{hpp,cpp}`
- Move cursor_id and SelectionRegion to cursor_defs.hpp
- Extract quest log rendering to `panels/quest_log.{hpp,cpp}`
- Extract drlg quest setpiece logic to `levels/drlg_quests.{hpp,cpp}`
- Extract quest data loading to `tables/questdat.{hpp,cpp}`
- Move `GameData` and `gbIsMultiplayer` into `game_mode.{hpp,cpp}`
- Add `parse_sfx_id.{hpp,cpp}`
- Update CMake libraries accordingly

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-08-23 06:08:15 +01:00
MoonBnuuy aff9a4a9c8 Restore AmigaOS build and runtime support (#8660) 2026-08-06 01:28:14 +00:00
Gleb MazovetskiyandClaude Fable 5 ac2d7fc731 Replace libfmt with std::format
- `fmt::format` with literal format strings -> `std::format`.
- `fmt::format(fmt::runtime(...))` -> `FormatRuntime` in the new
  `utils/format.hpp`, a std::vformat wrapper that is also safe under the
  P2905 lvalue requirement of `std::make_format_args`.
- `fmt::dynamic_format_arg_store` (Lua logging) -> a small hand-rolled
  per-field formatter over `std::variant`, returning `std::expected`.
- `fmt::format_int` -> `std::to_chars`.
- `fmt::join` -> manual joins at the two call sites.
- SDL_audiolib: new patch that rewrites aulib_log.h to use std::format
  and drops the fmt dependency from its CMakeLists.
- The `-static-libstdc++` guard now keys off
  `DEVILUTIONX_STATIC_SDL_AUDIOLIB` instead of `DEVILUTIONX_STATIC_LIBFMT`.
- libfmt removed from CMake, vcpkg, Brewfile, CI workflows,
  Dockerfiles, packaging scripts, UWP project, and docs.
- macOS bumped to 13.3+, iOS to 16.3+ (required for `<format>`)
- Amiga m68k: provide `__cmpdf2`, which is missing from the hard-float
  libgcc multilib but referenced via libstdc++'s long double paths.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-22 00:00:04 +02:00
Gleb MazovetskiyandClaude Fable 5 63e85d9b1b Replace tl::expected with std::expected
Now that the project targets C++23, use the standard library's
std::expected instead of the vendored tl::expected polyfill:

- tl::expected -> std::expected, tl::unexpected/tl::make_unexpected -> std::unexpected
- .map()/.map_error() -> .transform()/.transform_error()
- #include <expected.hpp> -> #include <expected>, grouped with std headers
- Remove 3rdParty/tl/expected.hpp (the tl target remains for function_ref.hpp)

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-22 00:00:04 +02:00
Lawrence Caldwell 4f6ad78fc3 Report missing files in HeadlessMode instead of faking success
The loaders returned success with a null/empty buffer when a file could
not be opened in HeadlessMode, breaking every caller that probes
has_value() to pick between asset sources. With Diablo-only data the
Hellfire->Diablo town fallbacks (LoadLvlGFX / LoadMinData /
LoadLevelSOLData) never triggered: entering town dereferenced a null
town.min with uninitialized tileCount in SetDungeonMicros, a null
pMegaTiles in T_FillSector, and silently kept the previous level's
SOLData.

Files that do exist were already loaded identically in headless and
graphical builds; the special case only affected the missing-file path.
Headless code paths are a subset of the graphical ones, so reporting
the error exactly like the graphical build restores the intended
fallback behaviour with no call-site changes.
2026-07-18 12:58:54 +01:00
Anders Jenbo 1ca75e4776 Migrate DOS to SDL3 (fixing AUDIO and stuff) 2026-07-15 21:56:02 +02:00
Anders Jenbo 1bf1b9886a Mod hashing and manifest (#8608) 2026-07-12 07:37:22 -04:00
staphen c355728cc5 Use DirectoryExists() when looking for mod directories 2026-07-11 17:55:11 +02:00
Anders Jenbo 48aa2a5ba2 Block MP when overwrites are present 2026-07-08 13:45:41 -04:00
Gleb MazovetskiyandClaude Sonnet 5 f11d3c390f Update mpqfs
`mpqfs` API changed from bool/NULL return values and
a global `mpqfs_last_error()` to `mpqfs_error_code` return values.

`MpqArchive::Open/Clone now return `tl::expected<MpqArchive, std::string>`

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-07-03 23:55:02 +01:00
Gleb Mazovetskiy 34c4cfc2e7 Add missing <fmt/format.h> includes 2026-06-29 17:00:01 +01:00
Gleb Mazovetskiy 6ce6551cc4 Support Android Termux
Our CMake assumed that `ANDROID` meant we're compiling for Android from
a non-Android machine.

However, these days it's entirely possible to use an Android device as a
Linux machine (e.g. via Termux).
2026-06-29 17:00:01 +01:00
Stephen C. Wills e2a9dbd6ee Open Track integrity of assets that modify game engine logic 2026-06-22 00:02:05 +02:00
Gleb Mazovetskiy b85bc285f5 CLX rendering: Add some DVL_ASSUME hints
These don't currently seem to affect performance (GCC-15).
Still, they serve as documentation and perhaps future smarter
compilers can't take more advantage of it.
2026-06-12 18:01:20 +01:00
Gleb MazovetskiyandStephen C. Wills 61c69ebfbb Add Utf8CodePoints biderectional iterator
Co-authored-by: Stephen C. Wills <[email protected]>
2026-06-09 14:00:49 +01:00
Gleb MazovetskiyandClaude Sonnet 4.6 31a9b264f9 Optimize dun_render FullyDark and FullyLit paths
Add overlapped_memset.hpp with FillBytesUpTo32, FillBytesUpTo64 (moved
from light_render.cpp), and CopyBytesUpTo32. All three avoid PLT/IFUNC
dispatch overhead for small variable-length memset/memcpy calls on Linux
by using fixed-size inline memcpy calls with overlapping stores/loads.

- RenderLineOpaque<FullyDark>: use FillBytesUpTo32 instead of memset.
  Fixes ~3x slowdown vs PartiallyLit on the TransparentSquare RLE path.
- RenderLineOpaque<FullyLit>: use CopyBytesUpTo32 instead of memcpy.
  TransparentSquare FullyLit was 6x slower than FullyDark despite doing
  less work per pixel; now on par with FullyDark (~5.8x improvement).
- Remove RenderTriangleLower/Upper<FullyDark, false> loop specializations.
  Falling back to the unrolled N-template lets the compiler see each blit
  width as a compile-time constant: FullyDark triangles ~5x faster,
  trapezoids ~2x faster, RenderBlackTile ~4x faster.
- RenderLineTransparentOrOpaqueN: for static N, bypass the fill/copy
  helpers and call BlitFillDirect (FullyDark) or BlitPixelsDirect (FullyLit)
  directly, guaranteeing a single vector instruction from the compiler.

Benchmarks (ns, RelWithDebInfo, single core, CPU scaling warnings apply):

Benchmark              | Baseline | +FillUpTo32 | -LoopSpecs | +CopyUpTo32
-----------------------|----------|-------------|------------|-----------
LTri  So/FL            |  7266 ns |     8377 ns |    7745 ns |    8427 ns
LTri  So/FD            | 21506 ns |    18274 ns |    4151 ns |    5758 ns
LTri  So/PL            | 69289 ns |    61874 ns |   60053 ns |   67337 ns
LTri  Tr/FL            | 83602 ns |    77991 ns |   79224 ns |   86274 ns
LTri  Tr/FD            | 70809 ns |    68356 ns |   62336 ns |   86026 ns
LTri  Tr/PL            |109707 ns |    95830 ns |   95321 ns |  103802 ns
RTri  So/FL            |  6220 ns |     5953 ns |    6052 ns |    7392 ns
RTri  So/FD            | 17101 ns |    17778 ns |    4145 ns |    4878 ns
RTri  So/PL            | 62913 ns |    63671 ns |   64209 ns |   70015 ns
RTri  Tr/FL            | 81890 ns |    81554 ns |   79492 ns |   82832 ns
RTri  Tr/FD            | 76801 ns |    66247 ns |   63267 ns |   77821 ns
RTri  Tr/PL            | 99755 ns |   102136 ns |  100410 ns |  104500 ns
TrSq  So/FL            |322304 ns |   340121 ns |  330975 ns |   56543 ns
TrSq  So/FD            |178437 ns |    63454 ns |   54919 ns |   57429 ns
TrSq  So/PL            |127834 ns |   141316 ns |  131048 ns |  147341 ns
TrSq  Tr/FL            |141366 ns |   142851 ns |  143384 ns |  153830 ns
TrSq  Tr/FD            |125299 ns |   121498 ns |  130854 ns |  133110 ns
TrSq  Tr/PL            |183519 ns |   177058 ns |  179739 ns |  177087 ns
Sq    So/FL            |  9618 ns |     8923 ns |    8291 ns |   10151 ns
Sq    So/FD            |  4885 ns |     5449 ns |    5426 ns |    9530 ns
Sq    So/PL            |118292 ns |   122309 ns |  118639 ns |  118512 ns
Sq    Tr/FL            |166114 ns |   165816 ns |  165845 ns |  167127 ns
Sq    Tr/FD            |113779 ns |   116176 ns |  113845 ns |  118415 ns
Sq    Tr/PL            |208899 ns |   210274 ns |  207931 ns |  208100 ns
LTrap So/FL            |  2386 ns |     2663 ns |    2389 ns |    2825 ns
LTrap So/FD            |  4159 ns |     3879 ns |    1723 ns |    1924 ns
LTrap So/PL            | 31172 ns |    30478 ns |   30913 ns |   31173 ns
LTrap Tr/FL            | 41760 ns |    46841 ns |   41622 ns |   42224 ns
LTrap Tr/FD            | 31138 ns |    31824 ns |   32467 ns |   33399 ns
LTrap Tr/PL            | 54863 ns |    52467 ns |   52177 ns |   53973 ns
RTrap So/FL            |  2387 ns |     2369 ns |    2280 ns |    3046 ns
RTrap So/FD            |  3901 ns |     3772 ns |    1522 ns |    1914 ns
RTrap So/PL            | 29838 ns |    30107 ns |   30544 ns |   34756 ns
RTrap Tr/FL            | 43348 ns |    41696 ns |   40635 ns |   43537 ns
RTrap Tr/FD            | 32092 ns |    31350 ns |   31687 ns |   31598 ns
RTrap Tr/PL            | 52474 ns |    51980 ns |   51348 ns |   51540 ns
RenderBlackTile        |   98.7 ns |      107 ns |    21.2 ns |    23.8 ns

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-06-07 13:19:02 +01:00
Nick Wicked 2a2d7fb3d1 Marching Squares Light Render bugfix (#8573) 2026-05-31 21:16:34 +00:00
Gleb MazovetskiyandClaude Sonnet 4.6 4c7d80c018 Optimize light_render: ~40% faster BuildLightmap
Five independent improvements measured via light_render_benchmark
(RelWithDebInfo, baseline 66,322 ns):

- Replace integer division in Interpolate with a 240-byte constexpr
  lookup table indexed by (lightLevel - q1, q2 - q1). Saves an idiv
  per interpolated edge. (~1%)

- Make DecrementTowardZero branchless: `num - ((num >> 31) | 1)`.
  Called 6x per row in the RenderTriangle inner loop, so branch
  misprediction cost adds up. (~6%)

- Iterate the light-level loop from maxLight down to minLight directly
  instead of scanning all LightsMax levels with continue/break. Cuts
  up to 14 spurious iterations per cell. (~8%)

- Cache adjacent quad values across columns. (~3%)

- Replace memset with FillBytes in hot paths (~30% faster)

Final: ~38,000ns (~40% faster)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-05-27 00:59:34 +09:00
Chris V. 04689419a8 Improve Emscripten build (#8312) 2026-05-21 05:39:30 +02:00
Anders Jenbo 7b65d70419 Implement audio via SDL3_mixer 2026-04-12 08:04:46 +02:00
Anders Jenbo 005e7dcc23 chore: clang-tidy cleanup part 1 2026-04-03 22:57:48 +02:00
Anders Jenboandstaphen 6f319978e6 Migrate from libmpq to mpqfs (#8482)
Co-authored-by: staphen <[email protected]>
2026-03-30 00:14:11 +02:00
Scott RichmondandYuri Pourre 0ecc3edaed [QOL] The buy and sell functionality of NPC stores is now visually driven to align with the stash and Diablo 2 style of trading (#8434)
- Add repair buttons (including “Repair All”) with proper alignment, tooltips, and cursor hit areas
- Improve controller support:
- Fix grid snapping and cursor positioning across panels
- Allow pressing/releasing UI buttons
- Fix item selling and movement between panels (inventory, belt, store)
- Prevent invalid interactions:
- Disable tab/repair navigation while holding items
- Hide unavailable options for non-Smith vendors
- Fix UI issues:
- Item misalignment and snapping
- Floating gold cost display
- Level-up button overlapping store panel
- Fix vendor-specific issues:
- Correct tooltip for non-Smith vendors
- Clean up Adria dialog options
- Fix stability issues:
- Resolve segfault when selling items
- Refactor and cleanup:
- Unify store sell logic
- Remove unused and stale code
- Improve IsPlayerInStore() logic
- General bug fixes and UI interaction improvements
---------

Co-authored-by: Yuri Pourre <[email protected]>
2026-03-29 15:23:43 +02:00
Trihedraf 04cc99cbde LuaEvent > lua:: named functions. +lua_event.cpp 2026-03-04 17:50:04 -05:00
Stephen C. Wills 1b07a9d34c Release lock before finalizing sound samples (#8468) 2026-02-14 12:20:47 +01:00
Yuri Pourre d07a410639 First step to migrate accessibility features 2026-02-10 10:56:22 +01:00
Eric Robinson 2e394d0f00 [QOL/UX] Multiplayer Player Colors (#8317) 2026-01-28 17:21:53 -05:00
Niv Baehr 4a5d7a6967 Fix crash on ZWSP 2026-01-14 16:39:42 +01:00
Yuri Pourre b684fd143c Adria refill mana as mod 2026-01-12 11:46:11 +00:00
Trihedraf 32a0666201 move floating damage nums to lua mod & add xp mod 2026-01-11 12:21:27 +01:00
Niv Baehr 0802c27532 Draw text line by line (#8379) 2025-12-28 00:14:31 +01:00
Yuri Pourre 1b1c399a9b Update all the files that do not have CRLF as line break 2025-12-23 13:08:46 +00:00
Eric Robinson 402d5a4a1b Render dirt in OOB area (#8331) 2025-12-13 09:01:51 +00:00
Eric Robinson c44890d8e4 Fix muted music on level transition (#8335) 2025-12-13 08:36:07 +00:00
staphen c55e7a4107 Reload sfx when reloading active mods 2025-12-05 23:30:27 +01:00
Eric Robinson bc0d60bff7 Add Player hasNoMana helper 2025-12-03 00:40:21 -05:00
Eric Robinson 7e8173e6ff Add Player hasNoLife helper (#8302) 2025-12-03 05:12:42 +00:00
Gleb Mazovetskiy 705a007c22 SDL3: Fix nearest-neighbor scaling
For some reason, setting the scaling on just `texture` still results
in bluriness. However, setting the default scaling mode on the renderer
fixes it.

Also, does a few more things the SDL3 way.
2025-10-25 16:17:51 +02:00
Gleb Mazovetskiy db9404dcf6 CMake: Add SDL3_mixer
Requires a not-yet-released SDL 3.4.0.

I tried implementing audio with plain SDL and it's too complicated.
2025-10-23 17:54:33 +01:00
Gleb Mazovetskiy fc1d447918 SDL3: Convert events to render coordinates
Fixes mouse clicks with hardware cursor + integer scaling.
2025-10-18 17:21:58 +01:00
Gleb Mazovetskiy 20ad675558 SDL3: Build with sound
This doesn't implement full sound support but stubs out most of the
sound code under SDL3, so that we can implement it piecemeal.

Implemented here:
1. Sound device initialization.
2. SVid sound playback.

Does not add a dependency on `SDL_mixer`: SDL3 built-ins
are enough to play SVid audio.
2025-10-18 17:21:58 +01:00
Anders Jenbo 6130351a69 SDL3: Port audio code 2025-10-11 02:55:55 +02:00
Anders Jenbo a60768a73f SDL3: Backport to SDL 3.2.0 2025-10-10 15:54:19 +02:00
Gleb Mazovetskiy 88f706e0d1 SDL3: Add some backports / compat helpers 2025-10-10 00:49:44 +01:00