fix hyrule magic decompression memory leak, misc housekeeping

This commit is contained in:
scawful
2024-02-03 00:04:21 -05:00
parent 13b588fa75
commit aed54f1493
10 changed files with 58 additions and 18 deletions

View File

@@ -275,11 +275,13 @@ absl::Status Overworld::DecompressAllMapTiles() {
for (int i = 0; i < size1; i++) {
bytes[i] = decomp[i];
}
free(decomp);
decomp = gfx::lc_lz2::Uncompress(rom()->data() + p1, &size2, 1);
bytes2.resize(size2);
for (int i = 0; i < size2; i++) {
bytes2[i] = decomp[i];
}
free(decomp);
OrganizeMapTiles(bytes, bytes2, i, sx, sy, ttpos);

View File

@@ -535,6 +535,8 @@ class Overworld : public SharedROM, public core::ExperimentFlags {
auto mutable_entrances() { return &all_entrances_; }
auto &holes() { return all_holes_; }
auto mutable_holes() { return &all_holes_; }
auto deleted_entrances() const { return deleted_entrances_; }
auto mutable_deleted_entrances() { return &deleted_entrances_; }
auto AreaPalette() const {
return overworld_maps_[current_map_].current_palette();
}
@@ -599,6 +601,8 @@ class Overworld : public SharedROM, public core::ExperimentFlags {
std::vector<OverworldItem> all_items_;
std::vector<std::vector<Sprite>> all_sprites_;
std::vector<uint64_t> deleted_entrances_;
std::vector<std::vector<uint8_t>> map_data_p1 =
std::vector<std::vector<uint8_t>>(kNumOverworldMaps);
std::vector<std::vector<uint8_t>> map_data_p2 =

View File

@@ -65,6 +65,8 @@ void OverworldMap::LoadAreaInfo() {
}
}
message_id_ = rom_.toint16(overworldMessages + (parent_ * 2));
if (index_ < 0x40) {
area_graphics_ = rom_[mapGfx + parent_];
area_palette_ = rom_[overworldMapPalette + parent_];
@@ -117,8 +119,6 @@ void OverworldMap::LoadAreaInfo() {
parent_ = 129;
}
message_id_ = rom_[overworldMessages + parent_];
area_palette_ = rom_[overworldSpecialPALGroup + parent_ - 0x80];
if ((index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) ||
index_ == 0x94) {