Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Source Edit] Small Bug-fix -> CWndBase class

~FlyFF DeV~
Joined
Mar 2, 2009
Messages
579
Reaction score
113
Yo,

was doing 1 thing and got kinda face-rolled by source so I fixed the "exploit" and now no more stupid nonsense crash when you are missing Texture declared in applet...

There ya go leeeeeeeeeeeechars:
Code:
void CWndBase::AdditionalSkinTexture( LPWORD pDest, CSize sizeSurface, D3DFORMAT d3dFormat )
{
    bool bSuccess = true;
    if( m_strTexture.IsEmpty() || IsVisible() == FALSE || IsWndStyle( WBS_NODRAWFRAME ) )
        return;
    
    if( m_bTile == false )
    {
        LPIMAGE lpImage;

        if( m_strWndTileMap.Lookup( m_strTexture, (void*&)lpImage ) == FALSE )
        {
            lpImage = new IMAGE;
            if( LoadImage( MakePath( DIR_THEME, m_strTexture ), lpImage ) == FALSE )
            {
                bSuccess = false;
                Error( "CWndBase::AdditionalSkinTexture Image %s Open1 Failed!", m_strTexture );
            }
            else
                m_strWndTileMap.SetAt( m_strTexture, lpImage );
        }
        ///////////////////////////////////////////////////////
        if( bSuccess )
        {
            CRect rect = GetWindowRect( TRUE );
            rect += ( m_pParentWnd->GetClientRect( TRUE ).TopLeft() - m_pParentWnd->GetWindowRect( TRUE ).TopLeft() );

        
            PaintTexture( pDest, lpImage, rect.TopLeft(), sizeSurface, d3dFormat );
        }
    }
    else
    {
        CString strTile = m_strTexture;
        CString strFileName;
        LPIMAGE lpImage[9];

        int nImgBit = IMGBIT_32;
        int i;
        for( i = 0; i < 9; i++ )
        {
            CString strTemp1 = strTile.Left( strTile.GetLength() - 6 );
            CString strTemp2 = strTile.Right( 4 );
            strFileName.Format( "%s%02d%s", strTemp1, i, strTemp2 );
            if( m_strWndTileMap.Lookup( strFileName, (void*&)lpImage[i] ) == FALSE )
            {
                lpImage[i] = new IMAGE;
                if( LoadImage( MakePath( DIR_THEME, strFileName ), lpImage[i] ) == FALSE )
                {
                    bSuccess = false;
                    Error( "CWndBase::AdditionalSkinTexture Image­ %s Open2 Failed", strFileName );
                }
                else
                    m_strWndTileMap.SetAt( strFileName, lpImage[i] );
            }
        }
        ///////////////////////////////////////////////////////
        CRect rect;
        if( m_pParentWnd && IsWndStyle( WBS_CHILD ) )
        {
            rect = GetWindowRect( TRUE );
            rect += ( m_pParentWnd->GetClientRect( TRUE ).TopLeft() - m_pParentWnd->GetWindowRect( TRUE ).TopLeft() );
        }
        else
            rect = GetWindowRect();

#define EDIT_HEIGHT 8
        if(    IsWndStyle( WBS_VSCROLL ) )
            rect.right -= 16;
        int nWidth = rect.Width() / 8;
        int nHeight = rect.Height() / EDIT_HEIGHT;
        CPoint point;
        for( i = 0; i < nHeight; i++ )
        {
            for( int j = 0; j < nWidth; j++ )
            {
                if( bSuccess )
                {
                    point = CPoint( j * 8, i * EDIT_HEIGHT ) + rect.TopLeft();
                    if( i == 0 )
                    {
                        if( j == 0 )
                            PaintTexture( pDest, lpImage[ 0 ], point, sizeSurface, d3dFormat );
                        else
                            if( j == nWidth - 1 )
                                PaintTexture( pDest, lpImage[ 2 ], point, sizeSurface, d3dFormat );
                            else
                                PaintTexture( pDest, lpImage[ 1 ], point, sizeSurface, d3dFormat );
                    }
                    else
                    if( i == nHeight - 1 )
                    {
                        if( j == 0 )
                            PaintTexture( pDest, lpImage[ 6 ], point, sizeSurface, d3dFormat );
                        else
                            if( j == nWidth - 1 )
                                PaintTexture( pDest, lpImage[ 8 ], point, sizeSurface, d3dFormat );
                            else
                                PaintTexture( pDest, lpImage[ 7 ], point, sizeSurface, d3dFormat );                    
                    }
                    else
                    {
                        if( j == 0 )
                            PaintTexture( pDest, lpImage[ 3 ], point, sizeSurface, d3dFormat );
                        else
                            if( j == nWidth - 1 )
                                PaintTexture( pDest, lpImage[ 5 ], point, sizeSurface, d3dFormat );
                            else
                                PaintTexture( pDest, lpImage[ 4 ], point, sizeSurface, d3dFormat );                    
                    }
                }
            }
        }
    }
}

If got any questions about that ask.


Do not forget to click the button below
 
Last edited:
Junior Spellweaver
Joined
Mar 15, 2010
Messages
151
Reaction score
77
FYI Sir, You left your Neuz.ini Option in the Code

g_Option.m_strThemePath


just alter:
Code:
if( LoadImage( MakePath( g_Option.m_strThemePath, m_strTexture ), lpImage ) == FALSE )

To:
Code:
if( LoadImage( MakePath( DIR_THEME, m_strTexture ), lpImage ) == FALSE )

Unless You feel like adding it to g_Option :)


Thanks for this release btw :)
 
~FlyFF DeV~
Joined
Mar 2, 2009
Messages
579
Reaction score
113
Josh,

FML thx for correcting me forgot about my own edit ;]
 
Initiate Mage
Joined
Oct 14, 2011
Messages
12
Reaction score
0
Jomex, if I have understand, it's for fix when we have lot of different texture on screen ?

(exemple, spawn 500 mammoth and neuz crash, it's fix it ?)
 
~FlyFF DeV~
Joined
Mar 2, 2009
Messages
579
Reaction score
113
Jomex, if I have understand, it's for fix when we have lot of different texture on screen ?

(exemple, spawn 500 mammoth and neuz crash, it's fix it ?)
Nope.

This is fix for crash if your window uses Tile or single texture file for background. What I mean is before it always rendered the texture no matter if it was in memory or not -> that's why game crashed, now it renders the background of window only if there is texture. Additionally I upgraded this function to add texture to list only if it exists so there are no bugs for sure. + Error looking readably.
 
Back
Top