refactor: Improve OverworldEditor File Handling and Code Clarity

- Added file utility header for improved resource path management.
- Enhanced ASM file handling by utilizing GetResourcePath for better compatibility across deployment scenarios.
- Cleaned up code formatting and comments for clarity, ensuring consistent indentation and readability.
- Deprecated feature flag for ZSCustomOverworld ASM application, simplifying the logic for version gating.
This commit is contained in:
scawful
2025-10-05 20:43:29 -04:00
parent f2c773dfea
commit d41fcb22a3

View File

@@ -34,6 +34,7 @@
#include "app/zelda3/overworld/overworld_map.h"
#include "imgui/imgui.h"
#include "imgui_memory_editor.h"
#include "util/file_util.h"
#include "util/hex.h"
#include "util/log.h"
#include "util/macro.h"
@@ -2453,10 +2454,8 @@ absl::Status OverworldEditor::Clear() {
}
absl::Status OverworldEditor::ApplyZSCustomOverworldASM(int target_version) {
if (!core::FeatureFlags::get().overworld.kApplyZSCustomOverworldASM) {
return absl::FailedPreconditionError(
"ZSCustomOverworld ASM application is disabled in feature flags");
}
// Feature flag deprecated - ROM version gating is sufficient
// User explicitly clicked upgrade button, so respect their request
// Validate target version
if (target_version < 2 || target_version > 3) {
@@ -2483,18 +2482,23 @@ absl::Status OverworldEditor::ApplyZSCustomOverworldASM(int target_version) {
std::vector<uint8_t> working_rom_data = original_rom_data;
try {
// Determine which ASM file to apply
std::string asm_file_path;
if (target_version == 3) {
asm_file_path = "assets/asm/yaze.asm"; // Master file with v3
} else {
asm_file_path = "assets/asm/ZSCustomOverworld.asm"; // v2 standalone
}
// Determine which ASM file to apply and use GetResourcePath for proper resolution
std::string asm_file_name = (target_version == 3)
? "asm/yaze.asm" // Master file with v3
: "asm/ZSCustomOverworld.asm"; // v2 standalone
// Check if ASM file exists
// Use GetResourcePath to handle app bundles and various deployment scenarios
std::string asm_file_path = util::GetResourcePath(asm_file_name);
LOG_INFO("OverworldEditor", "Using ASM file: %s", asm_file_path.c_str());
// Verify file exists
if (!std::filesystem::exists(asm_file_path)) {
return absl::NotFoundError(
absl::StrFormat("ASM file not found: %s", asm_file_path));
return absl::NotFoundError(absl::StrFormat(
"ASM file not found at: %s\n\n"
"Expected location: assets/%s\n"
"Make sure the assets directory is accessible.",
asm_file_path, asm_file_name));
}
// Apply the ASM patch