Skip to content

Commit

Permalink
FF8: Fix game over crash with external textures (julianxhokaxhiu#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
myst6re authored Apr 17, 2024
1 parent 6e6322e commit b198d15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- **Important:** If you have installed [FFNx-v1.19.0.0](https://github.com/julianxhokaxhiu/FFNx/releases/tag/1.19.0), please remove the directories `mods/Textures/battle` and `mods/Textures/magic` and reinstall your battle mods if you had any. A lots of PNG textures has been wrongly dumped into those directories ( https://github.com/julianxhokaxhiu/FFNx/pull/685 )
- Rendering: Do not dump any textures if save_textures flag is false ( https://github.com/julianxhokaxhiu/FFNx/pull/685 )
- Rendering: Fix game over crash with external texture ( https://github.com/julianxhokaxhiu/FFNx/pull/686 )

# 1.19.0

Expand Down
8 changes: 8 additions & 0 deletions src/image/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,19 @@ bool loadPng(const char *filename, bimg::ImageMip &mip, bimg::TextureFormat::Enu
_width = png_get_image_width(png_ptr, info_ptr);
_height = png_get_image_height(png_ptr, info_ptr);

if (color_type == PNG_COLOR_TYPE_RGB && (targetFormat == bimg::TextureFormat::BGRA8 || targetFormat == bimg::TextureFormat::RGBA8)) {
ffnx_warning("%s: PNG files without alpha is not supported, please convert it to RGBA for improved performance\n", __func__);

return false;
}

rowptrs = png_get_rows(png_ptr, info_ptr);
rowbytes = png_get_rowbytes(png_ptr, info_ptr);

datasize = rowbytes * _height;

if (trace_all || trace_loaders) ffnx_trace("%s: data_size=%d width=%d height=%d bit_depth=%d color_type=%X\n", __func__, datasize, _width, _height, bit_depth, color_type);

if (!Renderer::doesItFitInMemory(datasize))
{
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
Expand Down

0 comments on commit b198d15

Please sign in to comment.