On CMake v3.28+, `EXCLUDE_FROM_ALL` is supported natively as an argument
to `FetchContent_Declare`.
On CMake v3.30+, `FetchContent_Populate`, which we use to polyfill
`EXCLUDE_FROM_ALL` support for older versions of CMake, is deprecated
and triggers a noisy warning.
Avoids the warning by using the native `EXCLUDE_FROM_ALL` support on
CMake v3.28+.
1. Updates the Dockerfile to the same image and flags as the CI.
2. Sets `-O2` as the default CMake Release flag rather than passing it
in a custom way.
Our implementation has a more modern interface and only
supports the features that we care about.
It always outputs `\n` as newlines and does not output BOM.
The modern interface eliminates awkward `c_str()/data()` conversions.
This implementation preserves comments and the file order of sections
and keys. New keys are written in insertion order.
We now also support modifying and adding default comments,
which may be a useful thing to do for the especially tricky
ini options (this PR doesn't add any but adds the ability to do so).
Sadly, this increases the RG99 binary size by 24 KiB.
I'm guessing this is because the map implementation generates
quite a bit of code.
Note that while it might seem that using `std::string` for every key and
value would do a lot of allocations, most of these strings are
small and thus benefit from Small String Optimization (= no allocations).
We may want to migrate this to 1 file per monster but for now the
migration is as close to the hard-coded version as possible.
Sprites that are used by multiple monsters are only loaded from disk
once.
1. `Events` global is replaced with `require('devilutionx.events')`.
2. Table is simplified and documented.
3. `On` removed from the event names as it was a bit redundant.
4. Functions are camelCase for consistency (e.g. `add` instead of
`Add`).
Example script:
```lua
local events = require("devilutionx.events")
local render = require("devilutionx.render")
local message = require("devilutionx.message")
local function greet()
message("Hello from " .. _VERSION)
print("Hello from ", _VERSION)
end
events.GameStart.add(greet)
local function drawGreet()
render.string("Hello from " .. _VERSION, 10, 40)
end
events.GameDrawComplete.add(drawGreet)
```
Runs lua/repl_prelude.lua at console initialization.
The default prelude contains global assignments for all devilutionx
modules. This should save us on typing.
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.
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.
Also added an iterator based API, though it's not useful for this use-case. Might be nice in the future?
The field/record iterators is single-pass input iterators with shared state.
To avoid rescanning fields unnecessarily parseInt currently can only be called once, it would be possible to make these iterators bidirectional with a bit of extra state (holding onto the start pointer)
Co-authored-by: Gleb Mazovetskiy <glex.spb@gmail.com>