285 Commits
Author SHA1 Message Date
Gleb Mazovetskiy a2b94cc03c Lua: Migrate and organize the rest of debug cmds
Fully migrates debug commands to Lua and organizes them into logical
groups.

The CLI `+` syntax now runs Lua, e.g.:

```bash
build/devilutionx '+dev.player.trn.plr("infra")'
```

Chat hotkeys run Lua code if they start with `/lua`, e.g.:

```ini
[NetMsg]
QuickMessage1=/lua message(dev.player.info())
```
2023-11-07 22:27:48 +00:00
Gleb Mazovetskiy 8bffbedcb4 Migrate some debug.cpp commands to Lua
Introduces a new `devilutionx.dev` Lua module, automatically loaded in
the console prelude.

Arguments and basic help are shown in autocompletion.
2023-11-04 20:28:27 +00: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
tetektoza e81407071f Debug: Add possibility to specify amount of gold in TakeGold cmd
Currently in GiveGold and TakeGold commands in debug.cpp we only have
a possibility to flood our inventory with gold, this patch adds a
possibility to either specify amount of gold to be added or just
write "max" which will preserve native functionality of those commands,
by clearing all gold or giving max gold possible (depending on the
amount of free slots in inventory).
2023-10-20 18:50:47 +02:00
tetektoza b5c3d4f1c6 Debug: Add possibility to specify amount of gold in GiveGold cmd
Currently in GiveGold and TakeGold commands in debug.cpp we only have a
possibility to flood our inventory with gold, this patch adds a
possibility to either specify amount of gold to be added or just write
"max" which will preserve native functionality of those commands, by
clearing all gold or giving max gold possible (depending on the amount
of free slots in inventory).
2023-10-20 18:50:47 +02: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 88bbf4f913 Improve DiabloMsg handling
1. Simplified implementation.
2. Now adjusts the box size to fit the content (e.g. when wrapping
   failed or when there are too many lines).
2023-10-14 09:45:24 +01:00
Gleb Mazovetskiy d1d27c8368 Rename error -> diablo_msg 2023-10-14 09:45:24 +01:00
tetektoza 41c5175444 Clip parsed level from debug console to 50
Currently, in givelvl command user can type lvl above 50, which is a
level cap. This patch clips it to 50, so we can prevent an accidential
freeze of the game caused by NetSendCmd loop if user types a really big
number.
2023-10-11 18:47:05 -04:00
staphen 7855dae582 Indicate network validation success or failure in iteminfo 2023-09-19 05:11:51 +02:00
Eric Robinson bc3a421622 Debug: Revise Text (#6625) 2023-09-19 00:43:30 +00:00
Eric Robinson 058a0d132d Debug: Improved iteminfo command (#6623) 2023-09-18 12:49:47 +02:00
KPhoenix 6dd8ce26a0 Debug: Convert DiabloMsg to EventPlrMsg 2023-09-18 12:26:22 +02:00
DakkJaniels 3d3cc31ebb add missing continue 2023-09-11 12:35:29 -04:00
DakkJaniels aba9d79a1a Fix spawn and spawnu (#6594) 2023-09-11 18:02:15 +02:00
Gleb Mazovetskiy 62e9aa0448 MissilePosition: Use WorldTilePosition
Reduces struct size and makes the types of coordinates more obvious.
2023-08-29 20:00:54 +01:00
Gleb Mazovetskiy 5355146d51 Use structured bindings 2023-08-29 12:56:49 +01: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 8c1a847f41 Remove utils/stdcompat/string_view.hpp 2023-08-14 09:59:14 +01:00
Gleb Mazovetskiy e9b5ec77f9 Remove AppendStrView 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 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 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 1167b92692 Remove uses of std::tolower
`std::tolower` relies on the C locale, which we try to avoid.
2023-06-18 04:55:47 +01:00
staphen 1cb367ab91 Move seedinfo to text commands 2023-06-04 02:36:52 +02:00
staphen 48caf5004f [Debug] Add more data to seedinfo 2023-06-03 12:02:08 +02:00
qndel c362808165 debug path command (#6101) 2023-05-13 10:20:15 +01:00
Gleb Mazovetskiy 4fa3732526 Add missing <cstdint> includes
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
2023-05-10 13:50:12 +01:00
obligaron bf86114ec3 Sync learned/changed spells 2023-04-24 18:19:27 +02:00
obligaron 7985a9211d Change Player::_pSplLvl to uint8_t 2023-04-24 18:19:27 +02:00
Anders Jenbo 3af438db93 Debug: Improve rendering of light gird
LightsMax is the darkest value, and the most common so lets not have that rendered all over the screen.
2023-04-19 01:13:49 +02:00
Anders Jenbo 6c893e4977 Remove unused code 2023-04-18 21:21:53 +02:00
obligaron 40bb3aeb45 Replace earflag with DeathReason 2023-04-14 23:34:54 +02:00
obligaron 590c990c80 Introduce Item::getName 2023-04-13 00:07:00 +02:00
obligaron 4cdd7ff2d9 Replace ReturnLevel/LevelTyp/LvlPosition 2023-03-12 19:30:57 +01:00
obligaron 0d2e43daa8 Add search monster/item/object debug commands 2023-02-26 04:40:31 +01:00
Gleb Mazovetskiy 1a1a282d9a Use C FILE instead of C++ streams throughout
Reduces binary size by ~2 KiB and may improve compatibility with oddball
systems (e.g. PS2).
2023-02-15 18:15:07 +00:00
KPhoenix 5794aefded Refactor debug commands 2023-02-06 01:58:49 +01:00
KPhoenix d813f13700 enum spell_id -> enum class SpellID 2023-02-05 10:24:58 +00:00
Gleb Mazovetskiy 1788d2f8ec Remove miniwin
Event handling code moved to `engine/events.{hpp,cpp}`.
2023-02-01 16:06:57 +00:00
obligaron 0c3b434d76 Make debug command restart compatible with multiplayer 2022-12-17 19:37:52 +01:00
KPhoenix c16b4932b1 Debug: Add maxstats and minstats command (#5539)
* Debug: Add maxstats command

Maxes all player stats

* clang

* Remove network command

* Add minstats command

* Improve functions
2022-11-27 10:26:54 -05:00
Gleb Mazovetskiy 680ab5ec40 Overhaul backbuffer state handling
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
2022-11-01 02:43:24 +00:00
Gleb Mazovetskiy 41f43ea3f5 Support unpacked MPQs from devilutionx-mpq-tools
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`
2022-10-11 18:00:57 +01:00
Gleb Mazovetskiy 188dc79f6e Make Players a vector 2022-08-26 13:22:04 +09:00
Gleb Mazovetskiy 6327e713e0 Lowercase all file paths
We want to be able to use unpacked MPQs on low-end platforms
(PS2/rg99/etc).

This is tricky on case-sensitive filesystems. Avoids case issues by
lowercasing all paths in the code (then we'll just need lowercased
listfiles).
2022-08-20 23:49:23 +01:00
qndel 5dc95550ce Add TRN debug command and support for optional class TRNs 2022-08-11 01:02:36 +02:00
qndel aa2b9dab74 fix debug questmap command (#5206) 2022-08-07 02:36:09 +02:00
Gleb Mazovetskiy ba34bafb3f Use SDL events directly
Removes redundant miniwin events and queue, using SDL events directly instead.

Demo migrated using this script: https://gist.github.com/glebm/8a73b04f695de96f344cc2e35151e03e
2022-08-03 03:50:19 +02:00