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())
```
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.
```lua
local render = devilutionx.render
local function drawGreet ()
render.string("Hello from " .. _VERSION, 10, 40)
end
Events.OnGameDrawComplete.Add(drawGreet)
```
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).
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).
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.
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 <ephphatha@thelettereph.com>
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.
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