diff --git a/source/lib/res/file/file_cache.cpp b/source/lib/res/file/file_cache.cpp index f8c2495dc8..446635cf70 100644 --- a/source/lib/res/file/file_cache.cpp +++ b/source/lib/res/file/file_cache.cpp @@ -321,13 +321,21 @@ public: void* alloc(size_t size) { - // safely handle 0 byte allocations. according to C/C++ tradition, - // we allocate a unique address, which ends up wasting 1 page. + // determine actual size to allocate + // .. better not be more than MAX_CACHE_SIZE - file_buf_alloc will + // fail because no amount of freeing up existing allocations + // would make enough room. therefore, check for this here + // (should never happen). + debug_assert(size < MAX_CACHE_SIZE); + // .. safely handle 0 byte allocations. according to C/C++ tradition, + // we allocate a unique address, which ends up wasting 1 page. if(!size) size = 1; - + // .. each allocation must be aligned to BUF_ALIGN, so + // we round up all sizes to that. const size_t size_pa = round_up(size, BUF_ALIGN); const uint size_class = size_class_of(size_pa); + void* p; // try to reuse a freed entry diff --git a/source/lib/res/file/vfs_optimizer.cpp b/source/lib/res/file/vfs_optimizer.cpp index f01bdf1860..d608738e90 100644 --- a/source/lib/res/file/vfs_optimizer.cpp +++ b/source/lib/res/file/vfs_optimizer.cpp @@ -476,7 +476,7 @@ public: //----------------------------------------------------------------------------- static const ssize_t REBUILD_MAIN_ARCHIVE_THRESHOLD = 50; -static const ssize_t BUILD_MINI_ARCHIVE_THRESHOLD = 15; +static const ssize_t BUILD_MINI_ARCHIVE_THRESHOLD = 20; typedef std::vector FnVector; static FnVector loose_files; diff --git a/source/lib/res/file/zip.cpp b/source/lib/res/file/zip.cpp index 50ac3f6038..fea2809bdd 100755 --- a/source/lib/res/file/zip.cpp +++ b/source/lib/res/file/zip.cpp @@ -296,7 +296,7 @@ LibError zip_populate_archive(File* f, Archive* a) if(ret < 0) { ret = za_find_ecdr_impl(f, 66000u, &ecdr); - // still failed - not a Zip file + // still failed - not a valid Zip file if(ret < 0) goto completely_bogus; } diff --git a/source/lib/res/graphics/tex_dds.cpp b/source/lib/res/graphics/tex_dds.cpp index a3fb05b5a0..73f0627139 100644 --- a/source/lib/res/graphics/tex_dds.cpp +++ b/source/lib/res/graphics/tex_dds.cpp @@ -402,15 +402,37 @@ static LibError decode_pf(const DDPIXELFORMAT* pf, uint* bpp_, uint* flags_) // .. uncompressed if(pf_flags & DDPF_RGB) { - const u32 pf_bpp = read_le32(&pf->dwRGBBitCount); - bpp = pf_bpp; // checked below + const u32 pf_bpp = read_le32(&pf->dwRGBBitCount); + const u32 pf_r_mask = read_le32(&pf->dwRBitMask); + const u32 pf_g_mask = read_le32(&pf->dwGBitMask); + const u32 pf_b_mask = read_le32(&pf->dwBBitMask); + const u32 pf_a_mask = read_le32(&pf->dwRGBAlphaBitMask); - // check for alpha channel - const u32 alpha_mask = read_le32(&pf->dwRGBAlphaBitMask); - if(alpha_mask && pf_flags & DDPF_ALPHAPIXELS) + // (checked below; must be set in case below warning is to be + // skipped) + bpp = pf_bpp; + + if(pf_flags & DDPF_ALPHAPIXELS) + { + // something weird other than RGBA or BGRA + if(pf_a_mask != 0xFF000000) + goto unsupported_component_ordering; flags |= TEX_ALPHA; + } - // note: we don't bother validating *BitMask. + // make sure component ordering is 0xBBGGRR = RGB (see below) + if(pf_r_mask != 0xFF || pf_g_mask != 0xFF00 || pf_b_mask != 0xFF0000) + { + // DDPIXELFORMAT in theory supports any ordering of R,G,B,A. + // we need to upload to OpenGL, which can only receive BGR(A) or + // RBG(A). the latter still requires conversion (done by driver), + // so it's slower. since the very purpose of supporting uncompressed + // DDS is storing images in a format that requires no processessing, + // we do not allow any weird orderings that require runtime work. + // instead, the artists must export with the correct settings. + unsupported_component_ordering: + /*/*WARN_RETURN(ERR_TEX_FMT_INVALID)*/; + } CHECK_ERR(tex_validate_plain_format(bpp, flags)); } diff --git a/source/lib/sysdep/win/wsdl.cpp b/source/lib/sysdep/win/wsdl.cpp index 85353e9cf4..03346981d4 100755 --- a/source/lib/sysdep/win/wsdl.cpp +++ b/source/lib/sysdep/win/wsdl.cpp @@ -805,7 +805,7 @@ static void mouse_update() } // moved outside of window else - queue_active_event(LOSE, SDL_APPMOUSEFOCUS); + active_change_state(LOSE, SDL_APPMOUSEFOCUS); } static uint mouse_buttons;