From 3201f0c152bbbd617182f12d53caa84f85b8c817 Mon Sep 17 00:00:00 2001 From: scawful Date: Tue, 28 May 2024 17:56:44 -0400 Subject: [PATCH] update Inventory::Create to return a status --- src/app/editor/screen_editor.cc | 2 +- src/app/zelda3/screen/inventory.cc | 7 ++++--- src/app/zelda3/screen/inventory.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app/editor/screen_editor.cc b/src/app/editor/screen_editor.cc index 2cf5ac7f..0fa15bb4 100644 --- a/src/app/editor/screen_editor.cc +++ b/src/app/editor/screen_editor.cc @@ -46,7 +46,7 @@ void ScreenEditor::DrawInventoryMenuEditor() { static bool create = false; if (!create && rom()->is_loaded()) { - inventory_.Create(); + status_ = inventory_.Create(); palette_ = inventory_.Palette(); create = true; } diff --git a/src/app/zelda3/screen/inventory.cc b/src/app/zelda3/screen/inventory.cc index 4cafb895..b33d4c77 100644 --- a/src/app/zelda3/screen/inventory.cc +++ b/src/app/zelda3/screen/inventory.cc @@ -10,12 +10,12 @@ namespace app { namespace zelda3 { namespace screen { -void Inventory::Create() { +absl::Status Inventory::Create() { data_.reserve(256 * 256); for (int i = 0; i < 256 * 256; i++) { data_.push_back(0xFF); } - PRINT_IF_ERROR(BuildTileset()) + RETURN_IF_ERROR(BuildTileset()) for (int i = 0; i < 0x500; i += 0x08) { tiles_.push_back(gfx::GetTilesInfo(rom()->toint16(i + kBowItemPos))); tiles_.push_back(gfx::GetTilesInfo(rom()->toint16(i + kBowItemPos + 0x02))); @@ -64,8 +64,9 @@ void Inventory::Create() { } bitmap_.Create(256, 256, 8, data_); - bitmap_.ApplyPalette(palette_); + RETURN_IF_ERROR(bitmap_.ApplyPalette(palette_)); rom()->RenderBitmap(&bitmap_); + return absl::OkStatus(); } absl::Status Inventory::BuildTileset() { diff --git a/src/app/zelda3/screen/inventory.h b/src/app/zelda3/screen/inventory.h index 6c1496c2..9f251aac 100644 --- a/src/app/zelda3/screen/inventory.h +++ b/src/app/zelda3/screen/inventory.h @@ -21,7 +21,7 @@ class Inventory : public SharedRom { auto Tilesheet() const { return tilesheets_bmp_; } auto Palette() const { return palette_; } - void Create(); + absl::Status Create(); private: absl::Status BuildTileset();