[nostalgia/core] Make invalid palette lookups return 0 instead of garbage memory
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user