Files
DevilutionX/Source/effects_stubs.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

72 lines
1.7 KiB
C++

// Stubbed implementations of effects for the NOSOUND mode.
#include "effects.h"
#include <expected>
#include <magic_enum/magic_enum.hpp>
#include "engine/random.hpp"
namespace devilution {
int sfxdelay;
SfxID sfxdnum;
bool effect_is_playing(SfxID nSFX) { return false; }
void stream_stop() { }
void PlaySFX(SfxID psfx)
{
switch (psfx) {
case SfxID::Warrior69:
case SfxID::Sorceror69:
case SfxID::Rogue69:
case SfxID::Monk69:
case SfxID::Swing:
case SfxID::SpellAcid:
case SfxID::OperateShrine:
case SfxID::Warrior14:
case SfxID::Warrior15:
case SfxID::Warrior16:
case SfxID::Warrior2:
case SfxID::Rogue14:
case SfxID::Sorceror14:
case SfxID::Monk14:
AdvanceRndSeed();
break;
default:
break;
}
}
void PlaySfxLoc(SfxID psfx, Point position, bool randomizeByCategory)
{
if (!randomizeByCategory)
return;
PlaySFX(psfx);
}
void sound_stop() { }
void sound_update() { }
void effects_cleanup_sfx(bool fullUnload) { }
void sound_init() { }
void ui_sound_init() { }
void effects_play_sound(SfxID id) { }
int GetSFXLength(SfxID nSFX) { return 0; }
std::expected<HeroSpeech, std::string> ParseHeroSpeech(std::string_view value)
{
const std::optional<HeroSpeech> enumValueOpt = magic_enum::enum_cast<HeroSpeech>(value);
if (enumValueOpt.has_value()) {
return enumValueOpt.value();
}
return std::unexpected("Unknown enum value.");
}
std::expected<SfxID, std::string> ParseSfxId(std::string_view value)
{
const std::optional<SfxID> enumValueOpt = magic_enum::enum_cast<SfxID>(value);
if (enumValueOpt.has_value()) {
return enumValueOpt.value();
}
return std::unexpected("Unknown enum value.");
}
} // namespace devilution