Skip to content

Commit

Permalink
Fixed partial output when decompiler error
Browse files Browse the repository at this point in the history
  • Loading branch information
grunt-lucas committed Sep 23, 2023
1 parent 700f2b9 commit b6e03c4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,17 @@ static void driveDecompile(PtContext &ctx)

validateDecompileOutputs(ctx, outputPath, attributesPath, bottomPath, middlePath, topPath);

std::ofstream outAttributes{attributesPath.string()};
std::ostringstream outAttributesContent{};
std::size_t metatileCount = attributesMap.size();
std::size_t imageHeight = std::ceil(metatileCount / 8.0) * 16;
png::image<png::rgba_pixel> bottomPrimaryPng{128, static_cast<png::uint_32>(imageHeight)};
png::image<png::rgba_pixel> middlePrimaryPng{128, static_cast<png::uint_32>(imageHeight)};
png::image<png::rgba_pixel> topPrimaryPng{128, static_cast<png::uint_32>(imageHeight)};
// FIXME : if any errors are thrown in this method, it will partially emit the attr file which is not intuitive
porytiles::emitDecompiled(ctx, bottomPrimaryPng, middlePrimaryPng, topPrimaryPng, outAttributes, *decompiled,
porytiles::emitDecompiled(ctx, bottomPrimaryPng, middlePrimaryPng, topPrimaryPng, outAttributesContent, *decompiled,
attributesMap, behaviorReverseMap);

std::ofstream outAttributes{attributesPath.string()};
outAttributes << outAttributesContent.str();
outAttributes.close();
bottomPrimaryPng.write(bottomPath);
middlePrimaryPng.write(middlePath);
Expand Down

0 comments on commit b6e03c4

Please sign in to comment.