Refactor dungeon room structures and rename classes for consistency

This commit is contained in:
scawful
2024-11-10 21:40:06 -05:00
parent a70414d803
commit b40699e81d
3 changed files with 51 additions and 68 deletions

View File

@@ -164,23 +164,23 @@ void Room::LoadRoomFromROM() {
b = rom_data[hpos];
pits_.TargetLayer = (uchar)(b & 0x03);
stair1_.TargetLayer = (uchar)((b >> 2) & 0x03);
stair2_.TargetLayer = (uchar)((b >> 4) & 0x03);
stair3_.TargetLayer = (uchar)((b >> 6) & 0x03);
pits_.target_layer = (uchar)(b & 0x03);
stair1_.target_layer = (uchar)((b >> 2) & 0x03);
stair2_.target_layer = (uchar)((b >> 4) & 0x03);
stair3_.target_layer = (uchar)((b >> 6) & 0x03);
hpos++;
stair4_.TargetLayer = (uchar)(rom_data[hpos] & 0x03);
stair4_.target_layer = (uchar)(rom_data[hpos] & 0x03);
hpos++;
pits_.Target = rom_data[hpos];
pits_.target = rom_data[hpos];
hpos++;
stair1_.Target = rom_data[hpos];
stair1_.target = rom_data[hpos];
hpos++;
stair2_.Target = rom_data[hpos];
stair2_.target = rom_data[hpos];
hpos++;
stair3_.Target = rom_data[hpos];
stair3_.target = rom_data[hpos];
hpos++;
stair4_.Target = rom_data[hpos];
stair4_.target = rom_data[hpos];
hpos++;
// Load room objects
@@ -375,7 +375,7 @@ void Room::LoadObjects() {
if (nbr_of_staircase < 4) {
tile_objects_.back().set_options(ObjectOption::Stairs |
tile_objects_.back().options());
staircase_rooms_vec_.push_back(StaircaseRooms(
staircase_rooms_vec_.push_back(z3_staircase(
posX, posY,
absl::StrCat("To ", staircase_rooms_[nbr_of_staircase])
.data()));
@@ -383,8 +383,7 @@ void Room::LoadObjects() {
} else {
tile_objects_.back().set_options(ObjectOption::Stairs |
tile_objects_.back().options());
staircase_rooms_vec_.push_back(
StaircaseRooms(posX, posY, "To ???"));
staircase_rooms_vec_.push_back(z3_staircase(posX, posY, "To ???"));
}
}
}
@@ -480,7 +479,7 @@ void Room::LoadChests() {
}
chests_in_room_.emplace_back(
ChestData(rom_data[cpos + (i * 3) + 2], big));
z3_chest_data(rom_data[cpos + (i * 3) + 2], big));
}
}
}

View File

@@ -86,43 +86,6 @@ constexpr int NumberOfRooms = 296;
constexpr ushort stairsObjects[] = {0x139, 0x138, 0x13B, 0x12E, 0x12D};
class DungeonDestination {
public:
DungeonDestination() = default;
~DungeonDestination() = default;
DungeonDestination(uint8_t i) : Index(i) {}
uint8_t Index;
uint8_t Target = 0;
uint8_t TargetLayer = 0;
};
struct Chest {
uint8_t x = 0;
uint8_t y = 0;
uint8_t item = 0;
bool picker = false;
bool big_chest = false;
};
struct ChestData {
ChestData() = default;
ChestData(uchar i, bool s) : id_(i), size_(s) {};
uchar id_;
bool size_;
};
struct StaircaseRooms {
StaircaseRooms() = default;
StaircaseRooms(uchar i, uchar r, const char *label)
: id_(i), room_(r), label_(label) {};
uchar id_;
uchar room_;
const char *label_;
};
class Room : public SharedRom {
public:
Room() = default;
@@ -200,16 +163,16 @@ class Room : public SharedRom {
std::array<gfx::Bitmap, 3> background_bmps_;
std::vector<zelda3::Sprite> sprites_;
std::vector<StaircaseRooms> staircase_rooms_vec_;
std::vector<z3_staircase> staircase_rooms_vec_;
Background2 bg2_;
DungeonDestination pits_;
DungeonDestination stair1_;
DungeonDestination stair2_;
DungeonDestination stair3_;
DungeonDestination stair4_;
z3_dungeon_destination pits_;
z3_dungeon_destination stair1_;
z3_dungeon_destination stair2_;
z3_dungeon_destination stair3_;
z3_dungeon_destination stair4_;
std::vector<ChestData> chests_in_room_;
std::vector<z3_chest_data> chests_in_room_;
std::vector<RoomObject> tile_objects_;
std::vector<int> room_addresses_;