[nostalgia/core] Make invalid palette lookups return 0 instead of garbage memory

This commit is contained in:
2022-07-30 14:47:44 -05:00
parent c8dc14dd8e
commit 29fd9b8c4f
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -39,6 +39,13 @@ struct Palette {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette";
static constexpr auto TypeVersion = 1;
ox::Vector<Color16> colors = {};
[[nodiscard]]
constexpr Color16 color(auto idx) const noexcept {
if (idx < colors.size()) [[likely]] {
return colors[idx];
}
return 0;
}
};
// Predecessor to TileSheet, kept for backward compatibility