From c3a110bf2cc61ddcab8ac91405e5f4845706754a Mon Sep 17 00:00:00 2001 From: Garux Date: Sun, 10 Jun 2018 01:27:49 +0300 Subject: [PATCH] fix old mipmaps code: tex size could be = 0 --- radiant/textures.cpp | 8 ++------ radiant/texwindow.cpp | 6 +----- radiant/xywindow.cpp | 8 ++------ 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/radiant/textures.cpp b/radiant/textures.cpp index ee2e0124..497b849c 100644 --- a/radiant/textures.cpp +++ b/radiant/textures.cpp @@ -155,10 +155,6 @@ void ResampleGamma( float fGamma ){ } } -inline const int& min_int( const int& left, const int& right ){ - return std::min( left, right ); -} - int max_tex_size = 0; const int max_texture_quality = 3; LatchedInt g_Textures_textureQuality( 3, "Texture Quality" ); @@ -230,8 +226,8 @@ void LoadTextureRGBA( qtexture_t* q, unsigned char* pPixels, int nWidth, int nHe } int quality_reduction = max_texture_quality - g_Textures_textureQuality.m_value; - int target_width = min_int( gl_width >> quality_reduction, max_tex_size ); - int target_height = min_int( gl_height >> quality_reduction, max_tex_size ); + const int target_width = std::max( std::min( gl_width >> quality_reduction, max_tex_size ), 1 ); + const int target_height = std::max( std::min( gl_height >> quality_reduction, max_tex_size ), 1 ); while ( gl_width > target_width || gl_height > target_height ) { diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index fc0a9a0f..c795fb40 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -609,15 +609,11 @@ int TextureBrowser_TotalHeight( TextureBrowser& textureBrowser ){ return textureBrowser.m_nTotalHeight; } -inline const int& min_int( const int& left, const int& right ){ - return std::min( left, right ); -} - void TextureBrowser_clampOriginY( TextureBrowser& textureBrowser ){ if ( textureBrowser.originy > 0 ) { textureBrowser.originy = 0; } - int lower = min_int( textureBrowser.height - TextureBrowser_TotalHeight( textureBrowser ), 0 ); + const int lower = std::min( textureBrowser.height - TextureBrowser_TotalHeight( textureBrowser ), 0 ); if ( textureBrowser.originy < lower ) { textureBrowser.originy = lower; } diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index eb1ebfb2..809b0029 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -427,10 +427,6 @@ gboolean xywnd_chasemouse( gpointer data ){ return TRUE; } -inline const int& min_int( const int& left, const int& right ){ - return std::min( left, right ); -} - bool XYWnd::chaseMouseMotion( int pointx, int pointy ){ m_chasemouse_delta_x = 0; m_chasemouse_delta_y = 0; @@ -442,14 +438,14 @@ bool XYWnd::chaseMouseMotion( int pointx, int pointy ){ m_chasemouse_delta_x = std::max( pointx, 0 ) - epsilon; } else if ( ( pointx - m_nWidth ) > -epsilon ) { - m_chasemouse_delta_x = min_int( ( pointx - m_nWidth ), 0 ) + epsilon; + m_chasemouse_delta_x = std::min( ( pointx - m_nWidth ), 0 ) + epsilon; } if ( pointy < epsilon ) { m_chasemouse_delta_y = std::max( pointy, 0 ) - epsilon; } else if ( ( pointy - m_nHeight ) > -epsilon ) { - m_chasemouse_delta_y = min_int( ( pointy - m_nHeight ), 0 ) + epsilon; + m_chasemouse_delta_y = std::min( ( pointy - m_nHeight ), 0 ) + epsilon; } if ( m_chasemouse_delta_y != 0 || m_chasemouse_delta_x != 0 ) {