yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
chest_edit.h
Go to the documentation of this file.
1#ifndef YAZE_ZELDA3_DUNGEON_CHEST_EDIT_H_
2#define YAZE_ZELDA3_DUNGEON_CHEST_EDIT_H_
3
4#include <cstddef>
5#include <optional>
6#include <vector>
7
8#include "absl/status/status.h"
9#include "absl/status/statusor.h"
10#include "zelda.h"
12
13namespace yaze::zelda3 {
14
15// Stateful chests consume contents in encoded object-list order (0, 1, 2),
16// preserving vector order within each list. Special-table objects and fixed
17// open/minigame chest graphics do not consume ordinary contents records.
18std::optional<size_t> ChestIndexForObject(
19 const std::vector<RoomObject>& objects, size_t object_index);
20
21// Checks the one-to-one object/contents mapping without requiring known reward
22// IDs. Existing hack-specific receipt IDs remain editable and round-trip.
23absl::Status ValidateChestObjectMapping(const std::vector<RoomObject>& objects,
24 const std::vector<chest_data>& chests);
25
26// Plans contents for a candidate object edit without changing either input or
27// ROM bytes. Each candidate's source index identifies the original object;
28// nullopt creates a new object and repeated indices duplicate the same source.
29// Optional contents overrides are candidate-aligned (for example clipboard
30// rewards). New chests otherwise receive 1 rupee (receipt ID 0x34).
31//
32// Edits that preserve chest/lock identity, order, and type retain the original
33// contents, even in a room with an existing mapping mismatch. Affected mappings
34// require matching original records and a valid six-slot chest/lock ordering.
35// Global table capacity and save-region protection require the caller's
36// BuildChestSavePlan preflight before publishing the candidate.
37absl::StatusOr<std::vector<chest_data>> PlanChestObjectEdit(
38 const std::vector<RoomObject>& before_objects,
39 const std::vector<chest_data>& before_chests,
40 const std::vector<RoomObject>& after_objects,
41 const std::vector<std::optional<size_t>>& source_indices,
42 const std::vector<std::optional<chest_data>>& chest_overrides = {});
43
44} // namespace yaze::zelda3
45
46#endif // YAZE_ZELDA3_DUNGEON_CHEST_EDIT_H_
Zelda 3 specific classes and functions.
absl::Status ValidateChestObjectMapping(const std::vector< RoomObject > &objects, const std::vector< chest_data > &chests)
Definition chest_edit.cc:74
std::optional< size_t > ChestIndexForObject(const std::vector< RoomObject > &objects, size_t object_index)
Definition chest_edit.cc:63
absl::StatusOr< std::vector< chest_data > > PlanChestObjectEdit(const std::vector< RoomObject > &before_objects, const std::vector< chest_data > &before_chests, const std::vector< RoomObject > &after_objects, const std::vector< std::optional< size_t > > &source_indices, const std::vector< std::optional< chest_data > > &chest_overrides)
Definition chest_edit.cc:94
The Legend of Zelda: A Link to the Past - Data Structures and Constants.