Crash model viewer

10/22/2017 04:01 lancekie#1
my neuz crashes when i click item in /wiki

Neuz.exe caused an EXCEPTION_ACCESS_VIOLATION in module Neuz.exe at 0023:0048BB54, CWndModelView::OnDraw()+0596 byte(s), c:\users\asus\desktop\blessed flyff\source\_interface\wndmodelview.cpp, line 0123+0012 byte(s)

- Registers

EAX=00AC44F4 EBX=0019FC4C ECX=00000287 EDX=00000000 ESI=00000000
EDI=757350B0 EBP=0019FC40 ESP=0019F940 EIP=0048BB54 FLG=00210246
CS=0023 DS=002B SS=002B ES=002B FS=0053 GS=002B

0023:0048BB54 Neuz.exe, CWndModelView::OnDraw()+0596 byte(s)
0023:0051C7FD Neuz.exe, CWndBase::Paint()+0397 byte(s)
0023:0051C56E Neuz.exe, CWndBase::PaintRoot()+0574 byte(s)
0023:00474A00 Neuz.exe, CNeuzApp::Render()+0544 byte(s)
0023:0049B95F Neuz.exe, CD3DApplication::Render3DEnvironment()+0431 byte(s)
0023:0049B775 Neuz.exe, CD3DApplication::Run()+0245 byte(s)
0023:0047CE26 Neuz.exe, WinMain()+0342 byte(s)
0023:0092FDEC Neuz.exe, WinMainCRTStartup()+0388 byte(s)
0023:75738744 KERNEL32.DLL, BaseThreadInitThunk()+0036 byte(s)
0023:7700582D ntdll.dll, RtlGetAppContainerNamedObjectPath()+0253 byte(s)
0023:770057FD ntdll.dll, RtlGetAppContainerNamedObjectPath()+0205 byte(s)

:(:(:(

the error show this line in WndModelView.cpp
Code:
#include "stdafx.h"
#include "WndModelView.h"
#include "ResData.h"
#include "defineObj.h"
#include "DPClient.h"
extern CDPClient g_DPlay;


#ifdef __MODEL_VIEW
CWndModelView::CWndModelView( void ) 
{
	m_pTexture = NULL;
	m_pModel = NULL;
	m_bLButtonDownRot = FALSE;
	m_fRot  = 0.0f;
#ifdef __PMA_WING
	m_pMask = NULL;
#endif
}

CWndModelView::~CWndModelView( void )
{
	m_pTexture = NULL;
	SAFE_DELETE( m_pModel );
}
BOOL CWndModelView::Process()
{
	if( m_pModel )
		m_pModel->FrameMove();

#ifdef __PMA_WING
	if( m_pMask )
	{
		m_pMask->FrameMove();
	}
#endif

	return TRUE;
}
BOOL CWndModelView::Initialize( CWndBase* pWndParent, DWORD dwType )
{
    return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_MODEL_VIEW, 0, CPoint( 0, 0 ), pWndParent );
}
void CWndModelView::OnDraw( C2DRender* p2DRender )
{
	if( m_pModel == NULL )
		return;

	LPDIRECT3DDEVICE9 pd3dDevice = p2DRender->m_pd3dDevice;

	// ºäÆ÷Æ® ¼¼ÆÃ 
	D3DVIEWPORT9 viewport;

	viewport.X      = p2DRender->m_ptOrigin.x + 5;//100;// + 5;
	viewport.Y      = p2DRender->m_ptOrigin.y + 5;// + 5;
	viewport.Width  = p2DRender->m_clipRect.Width() - 100;//105;
	viewport.Height = 182;//p2DRender->m_clipRect.Height() - 200;
	viewport.MinZ   = 0.0f;
	viewport.MaxZ   = 1.0f;

	DWORD dwColor1 = D3DCOLOR_ARGB( 100, 0, 0,  0 );//D3DCOLOR_TEMP( 255,   0,   0,  50 );//
	DWORD dwColor2 = D3DCOLOR_ARGB( 255, 240, 240,  240 );//D3DCOLOR_TEMP( 255,  80,  80, 120 );//
	DWORD dwColor3 = D3DCOLOR_ARGB( 100, 200, 200,  200 );//D3DCOLOR_TEMP( 255,  80,  80, 120 );//

	pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
	pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
	pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
	pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
	pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );

	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
#ifdef __TEXTUR_FILTER
	if( !g_Option.b_TexFilter)
	{	
		pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );		
		pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
	}
	else
	{
		pd3dDevice->SetSamplerState( 0, D3DSAMP_MAXANISOTROPY, g_Option.n_FilterLevel );//Textur index 0 level 16(höchste stufe, extrem GPU lastig)
		pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC );
		pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC );
		if(g_Option.b_MipFilter)
			pd3dDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_ANISOTROPIC );
	}
#else
	pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );		
	pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
#endif

	pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );

	pd3dDevice->SetRenderState( D3DRS_AMBIENT,  D3DCOLOR_ARGB( 255, 255,255,255) );
	
	CRect rect = GetClientRect();

	// ºäÆ÷Æ® ¼¼ÆÃ 
	D3DXMATRIXA16 matWorld;
	D3DXMATRIXA16 matScale;
	D3DXMATRIXA16 matRot;
	D3DXMATRIXA16 matTrans;

	// Ä«¸Þ¶ó 
	D3DXMATRIX  matView;
	D3DXVECTOR3 vecLookAt( 0.0f, 0.0f, 3.0f );
	D3DXVECTOR3 vecPos(  0.0f, 0.7f, -3.5f );
	
	D3DXMatrixLookAtLH( &matView, &vecPos, &vecLookAt, &D3DXVECTOR3(0.0f,1.0f,0.0f) );
	
	pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
	
	#ifdef __YENV
	D3DXVECTOR3 vDir( 0.0f, 0.0f, 1.0f );
	SetLightVec( vDir );
	#endif //__YENV
	
	// ¿ÞÂÊ ¿øº» ¸ðµ¨ ·£´õ¸µ
	{
		LPWNDCTRL lpFace = GetWndCtrl( WIDC_CUSTOM1 );

[COLOR="Red"]		viewport.X      = p2DRender->m_ptOrigin.x + lpFace->rect.left;[/COLOR]
		viewport.Y      = p2DRender->m_ptOrigin.y + lpFace->rect.top;
		viewport.Width  = lpFace->rect.Width();
		viewport.Height = lpFace->rect.Height();

		viewport.MinZ   = 0.0f;
		viewport.MaxZ   = 1.0f;
		pd3dDevice->SetViewport(&viewport);
		pd3dDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0xffa08080, 1.0f, 0 ) ;

		D3DXMATRIX matProj;
		D3DXMatrixIdentity( &matProj );
		FLOAT fAspect = ((FLOAT)viewport.Width) / (FLOAT)viewport.Height;
/*
		D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4.0f, fAspect, CWorld::m_fNearPlane - 0.01f, CWorld::m_fFarPlane );
		pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
*/		
		FLOAT fov = D3DX_PI/4.0f;//796.0f;
		FLOAT h = cos(fov/2) / sin(fov/2);
		FLOAT w = h * fAspect;
		D3DXMatrixOrthoLH( &matProj, w, h, CWorld::m_fNearPlane - 0.01f, CWorld::m_fFarPlane );
		pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
		
	    D3DXMatrixIdentity(&matScale);
		D3DXMatrixIdentity(&matRot);
		D3DXMatrixIdentity(&matTrans);
		D3DXMatrixIdentity(&matWorld);
		
		D3DXMatrixRotationY( &matRot, D3DXToRadian( m_fRot ) );
		
		D3DXMatrixScaling(&matScale,1.2f,1.2f,1.2f);
		D3DXMatrixTranslation(&matTrans,0.0f,-0.6f,0.0f);
		
		D3DXMatrixMultiply(&matWorld,&matWorld,&matScale);
		D3DXMatrixMultiply(&matWorld, &matWorld, &matRot );
		D3DXMatrixMultiply(&matWorld, &matWorld, &matTrans );
		pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

		// ·£´õ¸µ 
		pd3dDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
		pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );//m_bViewLight );
		
		::SetLight( FALSE );
		::SetFog( FALSE );
		SetDiffuse( 1.0f, 1.0f, 1.0f );
		SetAmbient( 1.0f, 1.0f, 1.0f );

		m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[0] = g_pPlayer->m_fHairColorR;
		m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[1] = g_pPlayer->m_fHairColorG;
		m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[2] = g_pPlayer->m_fHairColorB;

		D3DXVECTOR4 vConst( 1.0f, 1.0f, 1.0f, 1.0f );
	#ifdef __YENV
		g_Neuz.m_pEffect->SetVector( g_Neuz.m_hvFog, &vConst );
	#else //__YENV						
		pd3dDevice->SetVertexShaderConstantF( 95, (float*)&vConst, 1 );
	#endif //__YENV
		::SetTransformView( matView );
		::SetTransformProj( matProj );
			
		m_Mover.OverCoatItemRenderCheck(m_pModel);

		// Çï¸äÀÌ ¸Ó¸®Ä«¶ô ³¯·Á¾ßÇϴ°ÍÀ̳Ä?  // Àκ¥ÀÌ ¾ø´Â°æ¿ì
			DWORD dwId	= m_Mover.m_aEquipInfo[PARTS_CAP].dwId;
			O3D_ELEMENT*	pElement = NULL;
			ItemProp*		pItemProp = NULL;
			
			if( dwId != NULL_ID )
			{
				pItemProp	= prj.GetItemProp( dwId );
				
				if( pItemProp && pItemProp->dwBasePartsIgnore != -1 )
				{
					pElement = m_pModel->SetEffect(pItemProp->dwBasePartsIgnore, XE_HIDE );
				}
				
				// ¿ÜÅõÀÇ»óÀ» ÀÔ¾úÀ»°æ¿ì ¸Ó¸®³¯¸±°ÍÀΰ¡ÀÇ ±âÁØÀ» ¿ÜÅõ ¸ðÀÚ¸¦ ±âÁØÀ¸·Î ¹Ù²Û´Ù
				dwId	= m_Mover.m_aEquipInfo[PARTS_HAT].dwId;
				if( dwId != NULL_ID )
				{
					if( !(m_Mover.m_aEquipInfo[PARTS_HAT].byFlag & CItemElem::expired) )
					{
						pItemProp	= prj.GetItemProp( dwId );
						if( pItemProp && pItemProp->dwBasePartsIgnore != -1 )
						{
							if( pItemProp->dwBasePartsIgnore == PARTS_HEAD )
								((CModelObject*)m_pModel)->SetEffect(PARTS_HAIR, XE_HIDE );
							
							((CModelObject*)m_pModel)->SetEffect(pItemProp->dwBasePartsIgnore, XE_HIDE );
						}
						else
						{
							if( pElement )
								pElement->m_nEffect &= ~XE_HIDE;
						}
					}
				}
									
			}
			else
			{
				// ¿ÜÅõÀÇ»óÀ» ÀÔ¾úÀ»°æ¿ì ¸Ó¸®³¯¸±°ÍÀΰ¡ÀÇ ±âÁØÀ» ¿ÜÅõ ¸ðÀÚ¸¦ ±âÁØÀ¸·Î ¹Ù²Û´Ù

				dwId = m_Mover.m_aEquipInfo[PARTS_HAT].dwId;
				if( dwId != NULL_ID )
				{
					if( !(m_Mover.m_aEquipInfo[PARTS_HAT].byFlag & CItemElem::expired) )
					{						
						pItemProp	= prj.GetItemProp( dwId );
						if( pItemProp && pItemProp->dwBasePartsIgnore != -1 )
						{
							if( pItemProp->dwBasePartsIgnore == PARTS_HEAD )
								((CModelObject*)m_pModel)->SetEffect(PARTS_HAIR, XE_HIDE );

							((CModelObject*)m_pModel)->SetEffect(pItemProp->dwBasePartsIgnore, XE_HIDE );
						}
					}
				}							
			}
			
		m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[0] = g_pPlayer->m_fHairColorR;
		m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[1] = g_pPlayer->m_fHairColorG;
		m_pModel->GetObject3D(PARTS_HAIR)->m_fAmbient[2] = g_pPlayer->m_fHairColorB;
			
		m_pModel->SetGroup( 0 );	
		m_pModel->Render( p2DRender->m_pd3dDevice, &matWorld );

#ifdef __PMA_WING
		D3DXMATRIX mMask = matWorld;

		if( m_pMask )
		{
			m_pMask->m_nNoEffect = m_pModel->m_nNoEffect;
			//D3DXMATRIX mRide = m_matWorld;
				static const int SPINE1_BONE = 4;	// ¸ö ºÎ±Ù ôÃß(³¯°³ÀÇ ¿òÁ÷ÀÓÀº ij¸¯ÅÍ ¸öÀÇ ¿òÁ÷ÀÓÀ» µû¸¥´Ù)
				static const int SPINE2_BONE = 5;	// ¸ñ ºÎ±Ù ôÃß(³¯°³°¡ ¸öÀÇ ¿òÁ÷ÀÓÀ» µû¸£´õ¶óµµ À§Ä¡´Â ¸ñ ºÎ±Ù¿¡ ºÙÀδÙ)
				D3DXMATRIX* pmatSpine1Bone = m_pModel->GetMatrixBone( SPINE1_BONE );
				D3DXMATRIX* pmatSpine2Bone = m_pModel->GetMatrixBone( SPINE2_BONE );
				if( pmatSpine1Bone && pmatSpine2Bone )
				{
					D3DXMATRIX matEvent;
					D3DXMatrixIdentity( &matEvent );

					pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
					D3DXMatrixTranslation( &matEvent, 0.2f, 0.0f, 0.1f );

					D3DXMATRIX matRotation;
					D3DXMatrixIdentity( &matRotation );
					D3DXMatrixRotationX( &matRotation, D3DXToRadian( 180 ) );
					D3DXMatrixMultiply( &matEvent, &matRotation, &matEvent );
					D3DXMatrixRotationZ( &matRotation, D3DXToRadian( -90 ) );
					D3DXMatrixMultiply( &matEvent, &matRotation, &matEvent );
					D3DXMatrixMultiply( &matEvent, &matEvent, pmatSpine1Bone );

					D3DXMatrixMultiply( &mMask, &matEvent, &matWorld );
				}
			
			m_pMask->SetTextureEx(m_pMask->m_pModelElem->m_nTextureEx);

			m_pMask->Render( pd3dDevice, &mMask );
			m_pMask->m_nNoEffect = 0;
		}

#endif
	}

	return;

}
void CWndModelView::OnInitialUpdate( void )
{
    CWndNeuz::OnInitialUpdate(); 
    RestoreDeviceObjects();
    MoveParentCenter();
	SAFE_DELETE( m_pModel );
	for( int i = 0; i < MAX_HUMAN_PARTS; ++i )
	{
		if( g_pPlayer->GetEquipItem(i) )
			m_Mover.m_aEquipInfo[i].dwId = g_pPlayer->GetEquipItem(i)->m_dwItemId;
	}

	int nMover = (g_pPlayer->GetSex() == SEX_MALE ? MI_MALE : MI_FEMALE);

	m_pModel = (CModelObject*)prj.m_modelMng.LoadModel( g_Neuz.m_pd3dDevice, OT_MOVER, nMover, TRUE );
	prj.m_modelMng.LoadMotion( m_pModel,  OT_MOVER, nMover, MTI_STAND );
	
	CMover::UpdateParts( g_pPlayer->GetSex(), g_pPlayer->m_dwSkinSet, g_pPlayer->m_dwFace, g_pPlayer->m_dwHairMesh, g_pPlayer->m_dwHeadMesh,m_Mover.m_aEquipInfo, m_pModel, NULL );
	m_pModel->InitDeviceObjects( g_Neuz.GetDevice() );
}

void CWndModelView::OnLButtonDown(UINT nFlags, CPoint point)
{
	SetCapture();
	if( GetWndCtrl(WIDC_CUSTOM1)->rect.PtInRect(point) )
	{
		m_ptOld = point;
		m_bLButtonDownRot = TRUE;
	}
}

void CWndModelView::OnLButtonUp(UINT nFlags, CPoint point)
{
	ReleaseCapture();
	m_bLButtonDownRot = FALSE;
}

void CWndModelView::OnMouseMove(UINT nFlags, CPoint point)
{
	if( m_bLButtonDownRot )
	{
		m_fRot += (m_ptOld.x - point.x) * 0.75f;
		m_ptOld = point;
	}
}

bool CWndModelView::SetPart(ItemProp *pProp)
{
	if( pProp )
	{
		if( pProp->dwParts < 2 || pProp->dwParts >= MAX_HUMAN_PARTS )
			return false;
		if( pProp->dwItemSex != NULL_ID && g_pPlayer->GetSex() != pProp->dwItemSex )
			return false;
		
		int nArryEquip1[5] = { PARTS_CAP, PARTS_UPPER_BODY, PARTS_HAND, PARTS_FOOT, PARTS_CLOAK };
		int nArryEquip2[5] = { PARTS_HAT, PARTS_CLOTH, PARTS_GLOVE, PARTS_BOOTS, PARTS_CLOAK2 };
		for( int i = 0; i < 5; ++i )
		{
			if( pProp->dwParts == nArryEquip1[i] )
			{
				m_Mover.m_aEquipInfo[nArryEquip2[i]].dwId = NULL_ID;
				break;
			}
			if( pProp->dwParts == nArryEquip2[i] )
			{
				m_Mover.m_aEquipInfo[nArryEquip1[i]].dwId = NULL_ID;
				break;
			}
		}
		m_Mover.m_aEquipInfo[pProp->dwParts].dwId = pProp->dwID;
#ifdef __PMA_WING
		if( pProp->dwParts == PARTS_MASK && pProp->dwItemKind3 == IK3_WING )
		{
			m_pMask	= (CModelObject*)prj.m_modelMng.LoadModel( D3DDEVICE, OT_ITEM, pProp->dwID );

			CString strMotion = m_pMask->GetMotionFileName( _T("stand") );
			m_pMask->LoadMotion( strMotion );
		}
		else
#endif
		{
#ifdef __PMA_WING
			if( pProp->dwParts == PARTS_MASK )
			{
				m_pMask = NULL;
			}
#endif
			CMover::UpdateParts(g_pPlayer->GetSex(),g_pPlayer->m_dwSkinSet,g_pPlayer->m_dwFace,g_pPlayer->m_dwHairMesh,g_pPlayer->m_dwHeadMesh,m_Mover.m_aEquipInfo,m_pModel,NULL);
		}
		return true;
	}
	return false;
}
#endif //__MODEL_VIEW