diff options
author | redruin1 <tfschaefer222@gmail.com> | 2022-10-18 08:38:02 +0300 |
---|---|---|
committer | redruin1 <tfschaefer222@gmail.com> | 2022-10-18 08:38:02 +0300 |
commit | 29ab984d5fcc4aff6796de591c448f354e5d92c3 (patch) | |
tree | 85a9aa1677a4df292b8efd18d0e90162857cc459 | |
parent | 5ff4ae6485dcb4d82eadcebaffca96057a0e841d (diff) |
cleanup push to test linux build for bugs
-rw-r--r-- | Libraries/minizip/unzip.c | 1 | ||||
-rw-r--r-- | Source/Graphics/heightmap.cpp | 8 | ||||
-rw-r--r-- | Source/Images/stbimage_wrapper.cpp | 2 | ||||
-rw-r--r-- | Source/Internal/assetpreload.cpp | 6 | ||||
-rw-r--r-- | Source/Internal/zip_util.cpp | 9 |
5 files changed, 14 insertions, 12 deletions
diff --git a/Libraries/minizip/unzip.c b/Libraries/minizip/unzip.c index bcfb9416..73af5ecd 100644 --- a/Libraries/minizip/unzip.c +++ b/Libraries/minizip/unzip.c @@ -1586,6 +1586,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; else { + //printf("%d\n", err); TRYFREE(pfile_in_zip_read_info); return err; } diff --git a/Source/Graphics/heightmap.cpp b/Source/Graphics/heightmap.cpp index b5f6d49e..c7cf8683 100644 --- a/Source/Graphics/heightmap.cpp +++ b/Source/Graphics/heightmap.cpp @@ -92,12 +92,8 @@ bool HeightmapImage::LoadData(const std::string& rel_path, HMScale scaled) { FindFilePath(rel_path.c_str(), abs_path, kPathSize, kDataPaths | kModPaths, true, NULL, &modsource); modsource_ = modsource; - // Tell stb to load with positive Y instead of negative Y - // FIXME: find a permanent home for this - stbi_set_flip_vertically_on_load(true); - int img_width = 0, img_height = 0, num_comp = 0; - unsigned short* data = stbi_load_16(abs_path, &img_width, &img_height, &num_comp, 0); + stbi_us* data = stbi_load_16(abs_path, &img_width, &img_height, &num_comp, 0); if (data == NULL) { FatalError("Error", "Could not load heightmap: %s", rel_path.c_str()); @@ -123,7 +119,7 @@ bool HeightmapImage::LoadData(const std::string& rel_path, HMScale scaled) { if (num_comp == 1) { // monochrome texture for (int z = 0; z < depth_; z++) { // flipped - unsigned short* bits = &data[((int)(z * z_scale)) * img_height]; + stbi_us* bits = &data[((int)(z * z_scale)) * img_height]; for (int x = 0; x < width_; x++) { // Convert unsigned shorts to floats height_data_[x + (((depth_ - 1) - z) * width_)] = (float)(bits[(int)(x * x_scale)]) / scale_factor; diff --git a/Source/Images/stbimage_wrapper.cpp b/Source/Images/stbimage_wrapper.cpp index 7450cfcf..a777f027 100644 --- a/Source/Images/stbimage_wrapper.cpp +++ b/Source/Images/stbimage_wrapper.cpp @@ -25,4 +25,4 @@ #define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION -#include "stbimage_wrapper.h"
\ No newline at end of file +#include "stbimage_wrapper.h" diff --git a/Source/Internal/assetpreload.cpp b/Source/Internal/assetpreload.cpp index 59ec4b1c..9d661f71 100644 --- a/Source/Internal/assetpreload.cpp +++ b/Source/Internal/assetpreload.cpp @@ -26,6 +26,7 @@ #include <Internal/filesystem.h> #include <Internal/path.h> +#include <Images/stbimage_wrapper.h> #include <XML/Parsers/levelassetspreloadparser.h> #include <cstring> @@ -45,6 +46,11 @@ AssetPreload& AssetPreload::Instance() { } void AssetPreload::Initialize() { + // Before we load any assets (in preload or otherwise): + // We set stb_image to flip images vertically to load them how Overgrowth expects (positive Y) + stbi_set_flip_vertically_on_load(true); + + // Now we can finish preloading Reload(); } diff --git a/Source/Internal/zip_util.cpp b/Source/Internal/zip_util.cpp index bac7202f..b71be2b3 100644 --- a/Source/Internal/zip_util.cpp +++ b/Source/Internal/zip_util.cpp @@ -396,7 +396,7 @@ void UnZipFile::ExtractAll(ExpandedZipFile& expanded_zip_file) { unsigned entry_id = 0; unsigned data_offset = 0; unsigned filename_offset = 0; - ScopedBuffer scoped_buf(size_buf); // raw malloc scoped to be less dangerous + ScopedBuffer scoped_buf(size_buf); // Raw malloc temp data scoped to be less dangerous unzGoToFirstFile(uf); do { int result; @@ -409,15 +409,15 @@ void UnZipFile::ExtractAll(ExpandedZipFile& expanded_zip_file) { } if (file_info.size_filename > 256) { FatalError("Error", "Zip file contains filename with length greater than 256"); + // TODO: get better user errors instead of codes } expanded_zip_file.SetEntry(entry_id, filename_offset, data_offset, file_info.uncompressed_size); ++entry_id; expanded_zip_file.SetFilename(filename_offset, filename_buf, file_info.size_filename + 1); filename_offset += file_info.size_filename + 1; - /*LOGI << file_info.version << std::endl; - LOGI << file_info.uncompressed_size << std::endl; - LOGI << filename_buf << std::endl;*/ + LOGI << uf << std::endl; + LOGI << scoped_buf.ptr << std::endl; result = unzOpenCurrentFile(uf); if (result != UNZ_OK) { @@ -428,7 +428,6 @@ void UnZipFile::ExtractAll(ExpandedZipFile& expanded_zip_file) { int bytes_read = 0; do { bytes_read = unzReadCurrentFile(uf, scoped_buf.ptr, size_buf); - LOGI << bytes_read << std::endl; // failure if (bytes_read < 0) { FatalError("Error", "Error reading from UnZip file (Error code: %d)", bytes_read); // TODO: get better user errors instead of codes |