Files
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

58 lines
1.6 KiB
C++

#include "lua/modules/monsters.hpp"
#include <string_view>
#include <sol/sol.hpp>
#include "data/file.hpp"
#include "engine/point.hpp"
#include "lua/metadoc.hpp"
#include "monster.h"
#include "tables/monstdat.h"
#include "utils/language.h"
#include "utils/str_split.hpp"
namespace devilution {
namespace {
void AddMonsterDataFromTsv(const std::string_view path)
{
DataFile dataFile = DataFile::loadOrDie(path);
LoadMonstDatFromFile(dataFile, path, true);
}
void AddUniqueMonsterDataFromTsv(const std::string_view path)
{
DataFile dataFile = DataFile::loadOrDie(path);
LoadUniqueMonstDatFromFile(dataFile, path);
}
void InitMonsterUserType(sol::state_view &lua)
{
sol::usertype<Monster> monsterType = lua.new_usertype<Monster>(sol::no_constructor);
LuaSetDocReadonlyProperty(monsterType, "position", "Point",
"Monster's current position (readonly)",
[](const Monster &monster) {
return Point { monster.position.tile };
});
LuaSetDocReadonlyProperty(monsterType, "id", "integer",
"Monster's unique ID (readonly)",
[](const Monster &monster) {
return static_cast<int>(reinterpret_cast<uintptr_t>(&monster));
});
}
} // namespace
sol::table LuaMonstersModule(sol::state_view &lua)
{
InitMonsterUserType(lua);
sol::table table = lua.create_table();
LuaSetDocFn(table, "addMonsterDataFromTsv", "(path: string)", AddMonsterDataFromTsv);
LuaSetDocFn(table, "addUniqueMonsterDataFromTsv", "(path: string)", AddUniqueMonsterDataFromTsv);
return table;
}
} // namespace devilution