yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
oracle_rom_safety_preflight.h
Go to the documentation of this file.
1#ifndef YAZE_APP_ZELDA3_DUNGEON_ORACLE_ROM_SAFETY_PREFLIGHT_H
2#define YAZE_APP_ZELDA3_DUNGEON_ORACLE_ROM_SAFETY_PREFLIGHT_H
3
4#include <string>
5#include <vector>
6
7#include "absl/status/status.h"
8#include "absl/status/statusor.h"
9
10namespace yaze {
11class Rom;
12}
13
14namespace yaze::zelda3 {
15
17 std::string code;
18 std::string message;
19 absl::StatusCode status_code = absl::StatusCode::kUnknown;
20 int room_id = -1; // -1 when the issue is not room-scoped.
21};
22
24 std::vector<OracleRomSafetyIssue> errors;
25
26 bool ok() const { return errors.empty(); }
27 absl::Status ToStatus() const;
28};
29
31 // Require Oracle's reserved WaterFill region to exist.
33 // Require expanded custom collision pointer/data support.
35 // Validate water-fill table header/content consistency.
37 // Validate custom-collision pointers/maps for all rooms.
39 // Limit per-room collision map errors to keep reports actionable.
41
42 // Room IDs that must have non-empty custom collision data authored.
43 //
44 // Use this to verify that game-mechanic-critical rooms (e.g. the D3 Kalyxo
45 // Castle prison escape room, which requires MinishSwitch collision geometry)
46 // have been fully authored before any write path is allowed to proceed.
47 //
48 // Rooms are checked independently of validate_custom_collision_maps.
49 // Errors use code "ORACLE_REQUIRED_ROOM_MISSING_COLLISION".
51};
52
53// Run Oracle ROM safety checks used by save/import write paths.
54//
55// Checks are fail-closed and return structured issues so callers can
56// surface detailed diagnostics and machine-readable reports.
58 Rom* rom, const OracleRomSafetyPreflightOptions& options = {});
59
60// Compute SHA-256 hash of a file, returning the lowercase hex string.
61//
62// Uses CommonCrypto (CC_SHA256) on macOS or falls back to shelling out
63// to platform hash utilities (certutil, sha256sum, or shasum).
64absl::StatusOr<std::string> ComputeSha256(const std::string& file_path);
65
66// Verify that the SHA-256 hash of a file matches an expected value.
67//
68// Returns OK if the hashes match, or a DataLoss status if they differ.
69absl::Status VerifySha256(const std::string& file_path,
70 const std::string& expected_hash);
71
72} // namespace yaze::zelda3
73
74#endif // YAZE_APP_ZELDA3_DUNGEON_ORACLE_ROM_SAFETY_PREFLIGHT_H
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Zelda 3 specific classes and functions.
absl::Status VerifySha256(const std::string &file_path, const std::string &expected_hash)
OracleRomSafetyPreflightResult RunOracleRomSafetyPreflight(Rom *rom, const OracleRomSafetyPreflightOptions &options)
absl::StatusOr< std::string > ComputeSha256(const std::string &file_path)