420 Commits
Author SHA1 Message Date
obligaron 48b2b7a50c Fix MSVC warnings in utils\* 2023-11-13 22:27:32 +01:00
Gleb Mazovetskiy 0d19c1b773 Slightly optimize loading same-sprite monsters
For monsters with the same sprite, load the sprite from the file system only once.

Example:

```
VERBOSE: Loaded monster graphics: falspear\phall   452 KiB   x1
VERBOSE: Loaded monster graphics: skelbow\sklbw    618 KiB   x1
VERBOSE: Loaded monster graphics: skelsd\sklsr     610 KiB   x1
VERBOSE: Loaded monster graphics: goatbow\goatb    832 KiB   x1
VERBOSE: Loaded monster graphics: bat\bat          282 KiB   x2 <-- here we only load the sprite once
VERBOSE: Loaded monster graphics: rhino\rhino     1306 KiB   x1
VERBOSE: Loaded monster graphics: golem\golem      298 KiB   x1
VERBOSE:  Total monster graphics:                 4401 KiB 4684 KiB
```

Here, the bat sprite will be loaded from the MPQ only once.
For the second sprite, we simply clone the first sprite before applying TRNs.

This also reduces the size of `MonsterData` from 88 bytes to 80.

When we migrate monster data to a TSV, the sprite IDs can be generated automatically at load time.
2023-11-10 06:01:40 +00:00
obligaron 45f8647892 Fix MSVC warnings in utils\* 2023-11-08 21:34:48 +00:00
obligaron 2b15eb8d03 Fix MSVC warnings from headers 2023-11-07 00:27:42 +01:00
obligaron 9bf1fd48b0 Fix a few MSVC warnings (#6782) 2023-11-05 18:23:53 +01:00
Gleb Mazovetskiy 3ea4996367 Add a basic Quake-style console
Enabled only in Debug mode.

Runs Lua similar to the `lua` CLI.
Supports multiline input with Shift+Enter.

Missing features:
1. Scrollback.
2. Input history on up/down.

Open with backtick, close with Esc.
2023-10-31 23:19:56 +00:00
Gleb Mazovetskiy de6eac137b Split up lua bindings a bit
```lua
local render = devilutionx.render

local function drawGreet ()
  render.string("Hello from " .. _VERSION, 10, 40)
end
Events.OnGameDrawComplete.Add(drawGreet)
```
2023-10-26 03:48:56 +01:00
Gleb Mazovetskiy fdb5738815 Add cursor support to DiabloUI and chat
Supports move left/right/home/end, backspace, delete, and Ctrl+V.
2023-10-24 01:56:54 +01:00
Gleb Mazovetskiy ddc3a9e54e lua: re-enable drawString 2023-10-16 19:22:33 +01:00
Gleb Mazovetskiy 64b94f9661 lua: add log{Verbose,Debug,Warn,Error} 2023-10-16 09:21:02 +01:00
Gleb Mazovetskiy 493aaf554e Add a lua debug command
Ideally we should have a better UI for this in the future.
2023-10-16 09:21:02 +01:00
Gleb Mazovetskiy 5b62bf7eec Lua improvements
1. A conformant `print`.
2. `drawString`.
3. `OnGameDrawComplete` event for drawing things on screen.
2023-10-15 19:47:12 +01:00
Gleb Mazovetskiy 60b12dcb2c lua: Register globals in a more efficient way 2023-10-15 19:47:12 +01:00
Gleb Mazovetskiy 5c1ff18bd3 LuaEvent: Use traverse_get 2023-10-15 19:47:12 +01:00
Gleb Mazovetskiy 72b49abef4 Add sol2 for Lua <-> C++ bindings 2023-10-15 14:53:08 +01:00
Anders Jenbo 706010ee45 Add Lua support 2023-10-08 21:33:51 +02:00
Anders Jenbo d725fdb4f3 Add screen reader support 2023-09-24 14:16:39 +02:00
Gleb Mazovetskiy c7fefd74b6 LoggedFstream: Fix OpenFile error check
Fixes #6626
2023-09-20 13:49:17 +01:00
Gleb Mazovetskiy bd0986ee73 Update NDK to v26
This version of NDK finally comes with updated libc++.
The last update to libc++ in NDK was in early 2020.

This update brings lots of improvements and bugfixes from upstream
libc++.

NDK 26 only support SDK 21+, so we bump `minSdkVersion` as well.
2023-09-20 02:04:50 +01:00
Gleb Mazovetskiy 13f6e34ebe Use an empty path for ini-based path detection
Avoids search paths duplication (`"./"` vs `""`)
2023-09-20 01:48:23 +01:00
Gleb Mazovetskiy 74977f68f6 Windows 9x: Return "" from SDL_GetPrefPath
Reduces noisy logging in stderr.txt.

On Windows9x there is no such thing as PrefPath, so there
is no point in trying to get/create one.

Also fixes `SDL_GetBasePath()` to return the directory path rather than
the exe path.
2023-09-20 01:33:53 +01:00
Gleb Mazovetskiy a44d1dfbf3 ResizeFile: Fix SetFilePointer return type check
`SetFilePointerEx` returns 0 on failure but `SetFilePointer` returns
`INVALID_SET_FILE_POINTER`.
2023-09-20 00:43:22 +01:00
Gleb Mazovetskiy a95bcc10f6 Windows 9x MinGW build (#6619) 2023-09-19 03:59:40 +00:00
Gleb Mazovetskiy e5c426c315 Make IsWall easier for the compiler to inline
This appears to be a very hot function.
Makes it fully inlineable (even in Debug mode).
2023-09-18 21:26:13 +01:00
Andrew James bb16b93836 move definition of non-templated function to cpp file (#6620) 2023-09-17 13:43:05 +01:00
ephphatha 3fda0586bd Add support for parsing fixed point decimal strings 2023-09-17 10:42:23 +01:00
Gleb Mazovetskiy 040c4fe82f Generalize support for Windows without wchar APIs
Replaces `NXDK` ifdefs that relate to the lack of wchar APIs
with the more general `DEVILUTIONX_WINDOWS_NO_WCHAR` ifdefs.

This should make it much easier to port to Windows 98.
2023-09-17 07:26:29 +01:00
Gleb Mazovetskiy b83637add8 Use a C array for transparency LUT for debug perf
In a debug build, `std::array` accesses are function calls.

Timedemo on my machine:
* Before: 45.39 seconds	141.3 FPS
* After:  40.20 seconds	159.5 FPS
2023-09-10 17:57:15 +01:00
Gleb Mazovetskiy c2ad6da733 Add DEVILUTIONX_DISPLAY_TEXTURE_FORMAT
Some platforms, such as PS2, can benefit from a different texture
format. Makes the texture format a CMake setting.
2023-09-03 00:48:06 +01:00
Stephen C. Wills 5e778431c3 Deterministic timer simulation for shrine messages in demo mode (#6516) 2023-08-29 13:46:49 +02:00
Gleb Mazovetskiy a3bf01f57b LoggedFread: Do not log EOF as an error
Usually we call fread in a loop until reaching EOF.
Reaching EOF is not an error, so we should not log it as such.

The error message was previously seen when loading demo files.
2023-08-27 15:59:03 +01:00
Anders Jenbo 15ed246239 Merge branch 'master' of github.com:diasurgical/devilutionX into development 2023-08-26 01:09:03 +02:00
Anders Jenbo 02ca96ba67 Bump Android build chain to the latest from Google to not upset them 2023-08-19 21:41:23 +02:00
Gleb Mazovetskiy ba4def9382 Use utils/algorithm/container.hpp in more places 2023-08-19 19:57:11 +09:00
Gleb Mazovetskiy ebe8c6e576 Add tl::expected and use it in ParseInt
`std::expected` has been standardized for C++23.
2023-08-19 17:13:54 +09:00
Gleb Mazovetskiy ecdf7380a8 PushAulibDecoder: Support 8-bit samples directly
Previously, we converted 8-bit audio to 16-bit, and then to float.
Eliminates the 8->16 conversion step.

Also optimizes the 16-bit conversion a bit.
2023-08-15 17:17:33 +09:00
Gleb Mazovetskiy d5446f2f01 Use std::variant in StringOrView
We also add a direct string move-assignment (`operator=(std::string &&)`),
which results in better codegen.

As a consequence, we have to replace `= {}` assignments with `= StringOrView {}`
because `= {}` is now ambiguous.
2023-08-14 10:55:02 +01:00
Gleb Mazovetskiy 8c1a847f41 Remove utils/stdcompat/string_view.hpp 2023-08-14 09:59:14 +01:00
Gleb Mazovetskiy 5960b20509 Remove a stray __cplusplus >= 201703L check 2023-08-14 01:54:29 +01:00
Gleb Mazovetskiy e9b5ec77f9 Remove AppendStrView 2023-08-14 01:54:29 +01:00
Gleb Mazovetskiy c19bfe87fa Remove utils/stdcompat/algorithm.hpp 2023-08-14 01:54:29 +01:00
Gleb Mazovetskiy 5cc1f98b8d Remove utils/stdcompat/invoke_result_t.hpp 2023-08-14 01:54:29 +01:00
Gleb Mazovetskiy 14540164a7 Remove utils/stdcompat/optional.hpp 2023-08-14 01:54:29 +01:00
Gleb Mazovetskiy 62d067b653 Remove utils/stdcompat/abs.hpp 2023-08-14 01:54:29 +01:00
Gleb Mazovetskiy 74755c8be7 Remove utils/stdcompat/cstddef.hpp 2023-08-14 01:54:29 +01:00
Gleb MazovetskiyandAndrew James 53db86ee9a Use std::from_chars instead of std::stoi
Adds a `ParseInt` function which uses `std::from_chars`.

From `std::from_chars` documentation:
> Unlike other parsing functions in C++ and C libraries,
> std::from_chars is locale-independent, non-allocating, and non-throwing.

Co-authored-by: Andrew James <[email protected]>
2023-08-13 21:43:53 +02:00
Gleb Mazovetskiy 2f1290c5d2 Remove C++11 compatibility code 2023-08-12 18:23:52 +02:00
Gleb Mazovetskiy 8101e2c0ba Add c_any_of and friends
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.
2023-08-12 16:24:01 +01:00
Gleb Mazovetskiy 6230ab34b6 Fix -Wunused-result for std::fread calls
Check the result of `fread` and friends explicitly rather than
calling `ferror`.
2023-07-13 04:23:25 +01:00
Gleb Mazovetskiy d8cd147ac7 Re-encode CL2 on load
Original Blizzard encoder is slightly less optimal than our encoder.

While size in RAM in less of a concern for the non-`UNPACKED_MPQS`
build, smaller files are faster to render.

Savings for unpacked and minified MPQs:
* diabdat.mpq: 918,311 bytes.
* hellfire.mpq: 313,882 bytes.

Example player graphics (note that only a few are loaded at any given time for single player):
* diabdat/plrgfx/warrior/: 366,564 bytes.

Example monster graphics savings:

* diabdat/monsters/skelbow: 5,391 bytes.

Based on the implementation from https://github.com/diasurgical/devilutionx-graphics-tools/pull/6
2023-07-13 01:44:16 +01:00