Files
DevilutionX/Source/engine/load_cel.cpp
T
Gleb MazovetskiyandClaude Fable 5 63e85d9b1b Replace tl::expected with std::expected
Now that the project targets C++23, use the standard library's
std::expected instead of the vendored tl::expected polyfill:

- tl::expected -> std::expected, tl::unexpected/tl::make_unexpected -> std::unexpected
- .map()/.map_error() -> .transform()/.transform_error()
- #include <expected.hpp> -> #include <expected>, grouped with std headers
- Remove 3rdParty/tl/expected.hpp (the tl target remains for function_ref.hpp)

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-22 00:00:04 +02:00

51 lines
1.4 KiB
C++

#include "engine/load_cel.hpp"
#include <cstddef>
#include <cstdint>
#include <expected>
#include <memory>
#include <string>
#ifdef DEBUG_CEL_TO_CL2_SIZE
#include <iostream>
#endif
#include "appfat.h"
#include "mpq/mpq_common.hpp"
#include "utils/status_macros.hpp"
#include "utils/str_cat.hpp"
#ifdef UNPACKED_MPQS
#include "engine/load_clx.hpp"
#else
#include "engine/load_file.hpp"
#include "utils/cel_to_clx.hpp"
#endif
namespace devilution {
std::expected<OwnedClxSpriteListOrSheet, std::string> LoadCelListOrSheetWithStatus(const char *pszName, PointerOrValue<uint16_t> widthOrWidths)
{
char path[MaxMpqPathSize];
*BufCopy(path, pszName, DEVILUTIONX_CEL_EXT) = '\0';
#ifdef UNPACKED_MPQS
return LoadClxListOrSheetWithStatus(path);
#else
size_t size;
ASSIGN_OR_RETURN(std::unique_ptr<uint8_t[]> data, LoadFileInMemWithStatus<uint8_t>(path, &size));
#ifdef DEBUG_CEL_TO_CL2_SIZE
std::cout << path;
#endif
return CelToClx(data.get(), size, widthOrWidths);
#endif
}
OwnedClxSpriteListOrSheet LoadCelListOrSheet(const char *pszName, PointerOrValue<uint16_t> widthOrWidths)
{
std::expected<OwnedClxSpriteListOrSheet, std::string> result = LoadCelListOrSheetWithStatus(pszName, widthOrWidths);
if (DVL_PREDICT_FALSE(!result.has_value())) app_fatal(result.error());
return std::move(result).value();
}
} // namespace devilution