From be32ee9797b463624c0a4b3545bd69c9bc00dcf3 Mon Sep 17 00:00:00 2001 From: scawful Date: Tue, 28 May 2024 17:29:21 -0400 Subject: [PATCH] fix all unhandled status return type compiler warnings --- src/app/core/common.h | 4 - src/app/editor/dungeon_editor.cc | 10 +- src/app/editor/dungeon_editor.h | 2 + src/app/editor/graphics_editor.cc | 14 +- src/app/editor/modules/palette_editor.cc | 4 +- src/app/editor/overworld_editor.cc | 14 +- src/app/editor/screen_editor.cc | 6 +- src/app/editor/screen_editor.h | 2 + src/app/rom.cc | 3 +- src/app/zelda3/dungeon/room_entrance.h | 185 +++++++++++++---------- src/cli/command_handler.cc | 3 +- 11 files changed, 138 insertions(+), 109 deletions(-) diff --git a/src/app/core/common.h b/src/app/core/common.h index e92f541b..27d5a589 100644 --- a/src/app/core/common.h +++ b/src/app/core/common.h @@ -211,10 +211,6 @@ uint16_t ldle16b_i(uint8_t const *const p_arr, size_t const p_index); uint16_t ldle16b(uint8_t const *const p_arr); void stle16b(uint8_t *const p_arr, uint16_t const p_val); -void stle32b(uint8_t *const p_arr, uint32_t const p_val); - -void stle32b_i(uint8_t *const p_arr, size_t const p_index, - uint32_t const p_val); } // namespace core } // namespace app diff --git a/src/app/editor/dungeon_editor.cc b/src/app/editor/dungeon_editor.cc index bd3d2b1a..6adc85a2 100644 --- a/src/app/editor/dungeon_editor.cc +++ b/src/app/editor/dungeon_editor.cc @@ -41,7 +41,7 @@ absl::Status DungeonEditor::Update() { TAB_BAR("##DungeonEditorTabBar") TAB_ITEM("Room Editor") - UpdateDungeonRoomView(); + status_ = UpdateDungeonRoomView(); END_TAB_ITEM() TAB_ITEM("Usage Statistics") if (is_loaded_) { @@ -107,8 +107,8 @@ absl::Status DungeonEditor::RefreshGraphics() { auto sprites_aux1_pal_group = rom()->palette_group().sprites_aux1; for (int i = 9; i < 16; i++) { int block = rooms_[current_room_id_].blocks()[i]; - graphics_bin_[block].get()->ApplyPaletteWithTransparent( - sprites_aux1_pal_group[current_palette_id_], 0); + RETURN_IF_ERROR(graphics_bin_[block].get()->ApplyPaletteWithTransparent( + sprites_aux1_pal_group[current_palette_id_], 0)); rom()->UpdateBitmap(graphics_bin_[block].get(), true); } return absl::OkStatus(); @@ -833,8 +833,8 @@ void DungeonEditor::DrawUsageGrid() { ImGui::Text("Floor1: %#02x", room.floor1); ImGui::Text("Floor2: %#02x", room.floor2); ImGui::Text("Message ID: %#04x", room.message_id_); - ImGui::Text("Size: %#06x", room.room_size()); - ImGui::Text("Size Pointer: %#06x", room.room_size_ptr()); + ImGui::Text("Size: %#016llx", room.room_size()); + ImGui::Text("Size Pointer: %#016llx", room.room_size_ptr()); ImGui::EndTooltip(); } diff --git a/src/app/editor/dungeon_editor.h b/src/app/editor/dungeon_editor.h index a2c748d0..38774e7c 100644 --- a/src/app/editor/dungeon_editor.h +++ b/src/app/editor/dungeon_editor.h @@ -141,6 +141,8 @@ class DungeonEditor : public Editor, std::unordered_map room_size_addresses_; std::unordered_map room_palette_; + + absl::Status status_; }; } // namespace editor diff --git a/src/app/editor/graphics_editor.cc b/src/app/editor/graphics_editor.cc index fba8bb4e..1370471e 100644 --- a/src/app/editor/graphics_editor.cc +++ b/src/app/editor/graphics_editor.cc @@ -435,7 +435,7 @@ absl::Status GraphicsEditor::UpdateScadView() { if (super_donkey_) { if (refresh_graphics_) { for (int i = 0; i < graphics_bin_.size(); i++) { - graphics_bin_[i].ApplyPalette( + status_ = graphics_bin_[i].ApplyPalette( col_file_palette_group_[current_palette_index_]); rom()->UpdateBitmap(&graphics_bin_[i]); } @@ -740,9 +740,9 @@ absl::Status GraphicsEditor::DecompressImportData(int size) { auto palette_group = rom()->palette_group().overworld_animated; z3_rom_palette_ = palette_group[current_palette_]; if (col_file_) { - bin_bitmap_.ApplyPalette(col_file_palette_); + status_ = bin_bitmap_.ApplyPalette(col_file_palette_); } else { - bin_bitmap_.ApplyPalette(z3_rom_palette_); + status_ = bin_bitmap_.ApplyPalette(z3_rom_palette_); } } @@ -765,7 +765,7 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() { gfx::Bitmap(core::kTilesheetWidth, core::kTilesheetHeight, core::kTilesheetDepth, converted_sheet); if (col_file_) { - graphics_bin_[i].ApplyPalette( + status_ = graphics_bin_[i].ApplyPalette( col_file_palette_group_[current_palette_index_]); } else { // ROM palette @@ -773,7 +773,7 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() { auto palette_group = rom()->palette_group().get_group( kPaletteGroupAddressesKeys[current_palette_]); z3_rom_palette_ = *palette_group->mutable_palette(current_palette_index_); - graphics_bin_[i].ApplyPalette(z3_rom_palette_); + status_ = graphics_bin_[i].ApplyPalette(z3_rom_palette_); } rom()->RenderBitmap(&graphics_bin_[i]); @@ -791,14 +791,14 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() { gfx::Bitmap(core::kTilesheetWidth, core::kTilesheetHeight, core::kTilesheetDepth, converted_sheet); if (col_file_) { - graphics_bin_[i].ApplyPalette( + status_ = graphics_bin_[i].ApplyPalette( col_file_palette_group_[current_palette_index_]); } else { // ROM palette auto palette_group = rom()->palette_group().get_group( kPaletteGroupAddressesKeys[current_palette_]); z3_rom_palette_ = *palette_group->mutable_palette(current_palette_index_); - graphics_bin_[i].ApplyPalette(z3_rom_palette_); + status_ = graphics_bin_[i].ApplyPalette(z3_rom_palette_); } rom()->RenderBitmap(&graphics_bin_[i]); diff --git a/src/app/editor/modules/palette_editor.cc b/src/app/editor/modules/palette_editor.cc index 8a2ffa85..3d240e6b 100644 --- a/src/app/editor/modules/palette_editor.cc +++ b/src/app/editor/modules/palette_editor.cc @@ -261,7 +261,7 @@ void PaletteEditor::DisplayPalette(gfx::SnesPalette& palette, bool loaded) { // Generate a default palette. The palette will persist and can be edited. static bool init = false; if (loaded && !init) { - InitializeSavedPalette(palette); + status_ = InitializeSavedPalette(palette); init = true; } @@ -333,7 +333,7 @@ void PaletteEditor::DisplayPalette(gfx::SnesPalette& palette, bool loaded) { void PaletteEditor::DrawPortablePalette(gfx::SnesPalette& palette) { static bool init = false; if (!init) { - InitializeSavedPalette(palette); + status_ = InitializeSavedPalette(palette); init = true; } diff --git a/src/app/editor/overworld_editor.cc b/src/app/editor/overworld_editor.cc index fd02ef82..b61586c5 100644 --- a/src/app/editor/overworld_editor.cc +++ b/src/app/editor/overworld_editor.cc @@ -818,7 +818,7 @@ absl::Status OverworldEditor::DrawTileSelector() { if (BeginTabBar(kTileSelectorTab.data(), ImGuiTabBarFlags_FittingPolicyScroll)) { if (BeginTabItem("Tile16")) { - RETURN_IF_ERROR(DrawTile16Selector()); + status_ = DrawTile16Selector(); EndTabItem(); } if (BeginTabItem("Tile8")) { @@ -830,7 +830,7 @@ absl::Status OverworldEditor::DrawTileSelector() { EndTabItem(); } if (BeginTabItem("Area Graphics")) { - DrawAreaGraphics(); + status_ = DrawAreaGraphics(); EndTabItem(); } EndTabBar(); @@ -1601,12 +1601,14 @@ absl::Status OverworldEditor::LoadGraphics() { palette_ = overworld_.AreaPalette(); // Create the area graphics image - rom()->CreateAndRenderBitmap(0x80, 0x200, 0x40, overworld_.current_graphics(), - current_gfx_bmp_, palette_); + RETURN_IF_ERROR(rom()->CreateAndRenderBitmap(0x80, 0x200, 0x40, + overworld_.current_graphics(), + current_gfx_bmp_, palette_)); // Create the tile16 blockset image - rom()->CreateAndRenderBitmap(0x80, 0x2000, 0x08, overworld_.Tile16Blockset(), - tile16_blockset_bmp_, palette_); + RETURN_IF_ERROR(rom()->CreateAndRenderBitmap(0x80, 0x2000, 0x08, + overworld_.Tile16Blockset(), + tile16_blockset_bmp_, palette_)); map_blockset_loaded_ = true; // Copy the tile16 data into individual tiles. diff --git a/src/app/editor/screen_editor.cc b/src/app/editor/screen_editor.cc index e4cac7c2..2cf5ac7f 100644 --- a/src/app/editor/screen_editor.cc +++ b/src/app/editor/screen_editor.cc @@ -74,7 +74,7 @@ void ScreenEditor::DrawInventoryMenuEditor() { tilesheet_canvas_.DrawOverlay(); ImGui::TableNextColumn(); - gui::DisplayPalette(palette_, create); + status_ = gui::DisplayPalette(palette_, create); ImGui::EndTable(); } @@ -233,8 +233,8 @@ absl::Status ScreenEditor::LoadDungeonMapTile16() { tile16_sheet_.ComposeTile16(rom()->graphics_buffer(), t1, t2, t3, t4); } - tile16_sheet_.mutable_bitmap()->ApplyPalette( - *rom()->mutable_dungeon_palette(3)); + RETURN_IF_ERROR(tile16_sheet_.mutable_bitmap()->ApplyPalette( + *rom()->mutable_dungeon_palette(3))); rom()->RenderBitmap(&*tile16_sheet_.mutable_bitmap().get()); for (int i = 0; i < tile16_sheet_.num_tiles(); ++i) { diff --git a/src/app/editor/screen_editor.h b/src/app/editor/screen_editor.h index 286c9230..468aa4b7 100644 --- a/src/app/editor/screen_editor.h +++ b/src/app/editor/screen_editor.h @@ -83,6 +83,8 @@ class ScreenEditor : public SharedRom { gfx::BitmapTable sheets_; gfx::Tilesheet tile16_sheet_; + + absl::Status status_; }; } // namespace editor diff --git a/src/app/rom.cc b/src/app/rom.cc index 14706aeb..d310f422 100644 --- a/src/app/rom.cc +++ b/src/app/rom.cc @@ -330,10 +330,11 @@ absl::Status Rom::SavePalette(int index, const std::string& group_name, } absl::Status Rom::SaveAllPalettes() { - palette_groups_.for_each([&](gfx::PaletteGroup& group) { + palette_groups_.for_each([&](gfx::PaletteGroup& group) -> absl::Status { for (size_t i = 0; i < group.size(); ++i) { RETURN_IF_ERROR(SavePalette(i, group.name(), *group.mutable_palette(i))); } + return absl::OkStatus(); }); return absl::OkStatus(); diff --git a/src/app/zelda3/dungeon/room_entrance.h b/src/app/zelda3/dungeon/room_entrance.h index 0819dd88..4e67bed6 100644 --- a/src/app/zelda3/dungeon/room_entrance.h +++ b/src/app/zelda3/dungeon/room_entrance.h @@ -209,89 +209,114 @@ class RoomEntrance { } } - void Save(Rom& rom, int entrance_id, bool is_spawn_point = false) { + absl::Status Save(Rom& rom, int entrance_id, bool is_spawn_point = false) { if (!is_spawn_point) { - rom.WriteShort(entrance_room + (entrance_id * 2), room_); - rom.WriteShort(entrance_yposition + (entrance_id * 2), y_position_); - rom.WriteShort(entrance_xposition + (entrance_id * 2), x_position_); - rom.WriteShort(entrance_yscroll + (entrance_id * 2), camera_y_); - rom.WriteShort(entrance_xscroll + (entrance_id * 2), camera_x_); - rom.WriteShort(entrance_cameraxtrigger + (entrance_id * 2), - camera_trigger_x_); - rom.WriteShort(entrance_cameraytrigger + (entrance_id * 2), - camera_trigger_y_); - - rom.WriteShort(entrance_exit + (entrance_id * 2), exit_); - rom.Write(entrance_blockset + entrance_id, (uint8_t)(blockset_ & 0xFF)); - rom.Write(entrance_music + entrance_id, (uint8_t)(music_ & 0xFF)); - rom.Write(entrance_dungeon + entrance_id, (uint8_t)(dungeon_id_ & 0xFF)); - rom.Write(entrance_door + entrance_id, (uint8_t)(door_ & 0xFF)); - rom.Write(entrance_floor + entrance_id, (uint8_t)(floor_ & 0xFF)); - rom.Write(entrance_ladderbg + entrance_id, (uint8_t)(ladder_bg_ & 0xFF)); - rom.Write(entrance_scrolling + entrance_id, (uint8_t)(scrolling_ & 0xFF)); - rom.Write(entrance_scrollquadrant + entrance_id, - (uint8_t)(scroll_quadrant_ & 0xFF)); - - rom.Write(entrance_scrolledge + 0 + (entrance_id * 8), - camera_boundary_qn_); - rom.Write(entrance_scrolledge + 1 + (entrance_id * 8), - camera_boundary_fn_); - rom.Write(entrance_scrolledge + 2 + (entrance_id * 8), - camera_boundary_qs_); - rom.Write(entrance_scrolledge + 3 + (entrance_id * 8), - camera_boundary_fs_); - rom.Write(entrance_scrolledge + 4 + (entrance_id * 8), - camera_boundary_qw_); - rom.Write(entrance_scrolledge + 5 + (entrance_id * 8), - camera_boundary_fw_); - rom.Write(entrance_scrolledge + 6 + (entrance_id * 8), - camera_boundary_qe_); - rom.Write(entrance_scrolledge + 7 + (entrance_id * 8), - camera_boundary_fe_); + RETURN_IF_ERROR( + rom.WriteShort(entrance_yposition + (entrance_id * 2), y_position_)); + RETURN_IF_ERROR( + rom.WriteShort(entrance_xposition + (entrance_id * 2), x_position_)); + RETURN_IF_ERROR( + rom.WriteShort(entrance_yscroll + (entrance_id * 2), camera_y_)); + RETURN_IF_ERROR( + rom.WriteShort(entrance_xscroll + (entrance_id * 2), camera_x_)); + RETURN_IF_ERROR(rom.WriteShort( + entrance_cameraxtrigger + (entrance_id * 2), camera_trigger_x_)); + RETURN_IF_ERROR(rom.WriteShort( + entrance_cameraytrigger + (entrance_id * 2), camera_trigger_y_)); + RETURN_IF_ERROR(rom.WriteShort(entrance_exit + (entrance_id * 2), exit_)); + RETURN_IF_ERROR(rom.Write(entrance_blockset + entrance_id, + (uint8_t)(blockset_ & 0xFF))); + RETURN_IF_ERROR( + rom.Write(entrance_music + entrance_id, (uint8_t)(music_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(entrance_dungeon + entrance_id, + (uint8_t)(dungeon_id_ & 0xFF))); + RETURN_IF_ERROR( + rom.Write(entrance_door + entrance_id, (uint8_t)(door_ & 0xFF))); + RETURN_IF_ERROR( + rom.Write(entrance_floor + entrance_id, (uint8_t)(floor_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(entrance_ladderbg + entrance_id, + (uint8_t)(ladder_bg_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(entrance_scrolling + entrance_id, + (uint8_t)(scrolling_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(entrance_scrollquadrant + entrance_id, + (uint8_t)(scroll_quadrant_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(entrance_scrolledge + 0 + (entrance_id * 8), + camera_boundary_qn_)); + RETURN_IF_ERROR(rom.Write(entrance_scrolledge + 1 + (entrance_id * 8), + camera_boundary_fn_)); + RETURN_IF_ERROR(rom.Write(entrance_scrolledge + 2 + (entrance_id * 8), + camera_boundary_qs_)); + RETURN_IF_ERROR(rom.Write(entrance_scrolledge + 3 + (entrance_id * 8), + camera_boundary_fs_)); + RETURN_IF_ERROR(rom.Write(entrance_scrolledge + 4 + (entrance_id * 8), + camera_boundary_qw_)); + RETURN_IF_ERROR(rom.Write(entrance_scrolledge + 5 + (entrance_id * 8), + camera_boundary_fw_)); + RETURN_IF_ERROR(rom.Write(entrance_scrolledge + 6 + (entrance_id * 8), + camera_boundary_qe_)); + RETURN_IF_ERROR(rom.Write(entrance_scrolledge + 7 + (entrance_id * 8), + camera_boundary_fe_)); } else { - rom.WriteShort(startingentrance_room + (entrance_id * 2), room_); - rom.WriteShort(startingentrance_yposition + (entrance_id * 2), - y_position_); - rom.WriteShort(startingentrance_xposition + (entrance_id * 2), - x_position_); - rom.WriteShort(startingentrance_yscroll + (entrance_id * 2), camera_y_); - rom.WriteShort(startingentrance_xscroll + (entrance_id * 2), camera_x_); - rom.WriteShort(startingentrance_cameraxtrigger + (entrance_id * 2), - camera_trigger_x_); - rom.WriteShort(startingentrance_cameraytrigger + (entrance_id * 2), - camera_trigger_y_); - rom.WriteShort(startingentrance_exit + (entrance_id * 2), exit_); - - rom.Write(startingentrance_blockset + entrance_id, - (uint8_t)(blockset_ & 0xFF)); - rom.Write(startingentrance_music + entrance_id, (uint8_t)(music_ & 0xFF)); - rom.Write(startingentrance_dungeon + entrance_id, - (uint8_t)(dungeon_id_ & 0xFF)); - rom.Write(startingentrance_door + entrance_id, (uint8_t)(door_ & 0xFF)); - rom.Write(startingentrance_floor + entrance_id, (uint8_t)(floor_ & 0xFF)); - rom.Write(startingentrance_ladderbg + entrance_id, - (uint8_t)(ladder_bg_ & 0xFF)); - rom.Write(startingentrance_scrolling + entrance_id, - (uint8_t)(scrolling_ & 0xFF)); - rom.Write(startingentrance_scrollquadrant + entrance_id, - (uint8_t)(scroll_quadrant_ & 0xFF)); - rom.Write(startingentrance_scrolledge + 0 + (entrance_id * 8), - camera_boundary_qn_); - rom.Write(startingentrance_scrolledge + 1 + (entrance_id * 8), - camera_boundary_fn_); - rom.Write(startingentrance_scrolledge + 2 + (entrance_id * 8), - camera_boundary_qs_); - rom.Write(startingentrance_scrolledge + 3 + (entrance_id * 8), - camera_boundary_fs_); - rom.Write(startingentrance_scrolledge + 4 + (entrance_id * 8), - camera_boundary_qw_); - rom.Write(startingentrance_scrolledge + 5 + (entrance_id * 8), - camera_boundary_fw_); - rom.Write(startingentrance_scrolledge + 6 + (entrance_id * 8), - camera_boundary_qe_); - rom.Write(startingentrance_scrolledge + 7 + (entrance_id * 8), - camera_boundary_fe_); + RETURN_IF_ERROR( + rom.WriteShort(startingentrance_room + (entrance_id * 2), room_)); + RETURN_IF_ERROR(rom.WriteShort( + startingentrance_yposition + (entrance_id * 2), y_position_)); + RETURN_IF_ERROR(rom.WriteShort( + startingentrance_xposition + (entrance_id * 2), x_position_)); + RETURN_IF_ERROR(rom.WriteShort( + startingentrance_yscroll + (entrance_id * 2), camera_y_)); + RETURN_IF_ERROR(rom.WriteShort( + startingentrance_xscroll + (entrance_id * 2), camera_x_)); + RETURN_IF_ERROR( + rom.WriteShort(startingentrance_cameraxtrigger + (entrance_id * 2), + camera_trigger_x_)); + RETURN_IF_ERROR( + rom.WriteShort(startingentrance_cameraytrigger + (entrance_id * 2), + camera_trigger_y_)); + RETURN_IF_ERROR( + rom.WriteShort(startingentrance_exit + (entrance_id * 2), exit_)); + RETURN_IF_ERROR(rom.Write(startingentrance_blockset + entrance_id, + (uint8_t)(blockset_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(startingentrance_music + entrance_id, + (uint8_t)(music_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(startingentrance_dungeon + entrance_id, + (uint8_t)(dungeon_id_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(startingentrance_door + entrance_id, + (uint8_t)(door_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(startingentrance_floor + entrance_id, + (uint8_t)(floor_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(startingentrance_ladderbg + entrance_id, + (uint8_t)(ladder_bg_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(startingentrance_scrolling + entrance_id, + (uint8_t)(scrolling_ & 0xFF))); + RETURN_IF_ERROR(rom.Write(startingentrance_scrollquadrant + entrance_id, + (uint8_t)(scroll_quadrant_ & 0xFF))); + RETURN_IF_ERROR( + rom.Write(startingentrance_scrolledge + 0 + (entrance_id * 8), + camera_boundary_qn_)); + RETURN_IF_ERROR( + rom.Write(startingentrance_scrolledge + 1 + (entrance_id * 8), + camera_boundary_fn_)); + RETURN_IF_ERROR( + rom.Write(startingentrance_scrolledge + 2 + (entrance_id * 8), + camera_boundary_qs_)); + RETURN_IF_ERROR( + rom.Write(startingentrance_scrolledge + 3 + (entrance_id * 8), + camera_boundary_fs_)); + RETURN_IF_ERROR( + rom.Write(startingentrance_scrolledge + 4 + (entrance_id * 8), + camera_boundary_qw_)); + RETURN_IF_ERROR( + rom.Write(startingentrance_scrolledge + 5 + (entrance_id * 8), + camera_boundary_fw_)); + RETURN_IF_ERROR( + rom.Write(startingentrance_scrolledge + 6 + (entrance_id * 8), + camera_boundary_qe_)); + RETURN_IF_ERROR( + rom.Write(startingentrance_scrolledge + 7 + (entrance_id * 8), + camera_boundary_fe_)); } + return absl::OkStatus(); } uint16_t entrance_id_; diff --git a/src/cli/command_handler.cc b/src/cli/command_handler.cc index 6b604c38..3878c8a9 100644 --- a/src/cli/command_handler.cc +++ b/src/cli/command_handler.cc @@ -65,7 +65,8 @@ absl::Status Tile16Transfer::handle(const std::vector& arg_vec) { // Transfer if user confirms if (userChoice == 'y' || userChoice == 'Y') { - dest_rom.WriteTile16(tile16_id_int, source_tile16_data); + RETURN_IF_ERROR( + dest_rom.WriteTile16(tile16_id_int, source_tile16_data)); std::cout << "Transferred tile16 ID " << tile16_id_int << " to dest rom." << std::endl; } else {