Merge branch 'fix-zero-lump-sfx' into 'master'

Fix zero lump sfx

Closes #789

See merge request KartKrew/Kart!1678
This commit is contained in:
Eidolon 2023-12-07 23:58:28 +00:00
commit 4627e9b17b
2 changed files with 11 additions and 6 deletions

View file

@ -214,7 +214,12 @@ optional<SoundChunk> try_load_gme(tcb::span<std::byte> data)
optional<SoundChunk> srb2::audio::try_load_chunk(tcb::span<std::byte> data)
{
optional<SoundChunk> ret;
optional<SoundChunk> ret = nullopt;
if (data.size() == 0)
{
return ret;
}
ret = try_load_dmx(data);
if (ret)
@ -232,5 +237,5 @@ optional<SoundChunk> srb2::audio::try_load_chunk(tcb::span<std::byte> data)
if (ret)
return ret;
return nullopt;
return ret;
}

View file

@ -431,10 +431,10 @@ public:
head = offset;
break;
case SeekFrom::kEnd:
if (-offset >= static_cast<StreamOffset>(span_.size())) {
if (static_cast<StreamOffset>(span_.size()) + offset < 0) {
throw std::logic_error("end offset is out of bounds");
}
head = span_.size() - offset;
head = span_.size() + offset;
break;
case SeekFrom::kCurrent:
if (head_ + offset < 0) {
@ -526,10 +526,10 @@ public:
head = offset;
break;
case SeekFrom::kEnd:
if (-offset >= static_cast<StreamOffset>(vec_.size())) {
if (static_cast<StreamOffset>(vec_.size()) + offset < 0) {
throw std::logic_error("end offset is out of bounds");
}
head = vec_.size() - offset;
head = vec_.size() + offset;
break;
case SeekFrom::kCurrent:
if (head_ + offset < 0) {