Skip to content

Commit

Permalink
Engine: fixed Overlay bitmap order read from legacy saves
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Oct 26, 2023
1 parent af61c8b commit 4bbc422
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions Engine/game/savegame_v321.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,9 @@ static void restore_game_ambientsounds(Stream *in, RestoredData &r_data)
}
}

static void ReadOverlays_Aligned(Stream *in, std::vector<bool> &has_bitmap, size_t num_overs)
static void ReadOverlays_Aligned(Stream *in, std::vector<int> &has_bitmap, size_t num_overs)
{
AlignedStream align_s(in, Common::kAligned_Read);
has_bitmap.resize(num_overs);
// Remember that overlay indexes may be non-sequential
auto &overs = get_overlays();
for (size_t i = 0; i < num_overs; ++i)
Expand All @@ -365,12 +364,10 @@ static void ReadOverlays_Aligned(Stream *in, std::vector<bool> &has_bitmap, size
if (over.type < 0)
continue; // safety abort
if (overs.size() <= static_cast<uint32_t>(over.type))
{
overs.resize(over.type + 1);
has_bitmap.resize(over.type + 1);
}
overs[over.type] = std::move(over);
has_bitmap[over.type] = has_bm;
if (has_bm)
has_bitmap.push_back(over.type);
}
}

Expand All @@ -381,11 +378,10 @@ static void restore_game_overlays(Stream *in, RestoredData &r_data)
// the vector may be resized during read
auto &overs = get_overlays();
overs.resize(num_overs);
std::vector<bool> has_bitmap(num_overs);
std::vector<int> has_bitmap;
ReadOverlays_Aligned(in, has_bitmap, num_overs);
for (size_t i = 0; i < overs.size(); ++i) {
if (has_bitmap[i])
r_data.OverlayImages[i].reset(read_serialized_bitmap(in));
for (auto over_id : has_bitmap) {
r_data.OverlayImages[over_id].reset(read_serialized_bitmap(in));
}
}

Expand Down

0 comments on commit 4bbc422

Please sign in to comment.