⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chritem.cpp

📁 网络游戏龙族服务器端管理工具 rmtool 源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	if(!CheckValidItem(nType, nNum))
		return NULL;

	return &m_pApp->m_ItemTable[ GetCurServerset() ][ nType ][ nNum ];
}

int CChrItem::GetCurServerset()
{
	CCharacterView* pView = (CCharacterView*)GetParent();
	return pView->m_nCurServerSet;
}

void CChrItem::SetItemViewOnlyView(int type, int num)
{
	if(CheckValidItem(type, num))	//蜡瓤茄 酒捞袍牢版快 
	{
		CCharacterView* pView = (CCharacterView*)GetParent(); 

		ItemData51* pData = GetItemPointer(	pView->m_nCurServerSet, type, num );


		char *type_to_name[11] = {	"PLANT", "MINERAL", "HERB", "COOK", "POTION", "TOOL", 
										"WEAPON", "DISPOSABLE", "ARMOR", "ACCESSORY", "ETC" };

		
		
		SetDlgItemText(IDC_VIEW_HAN_NAME, pData->han_name);
		SetDlgItemText(IDC_VIEW_TYPE, type_to_name[ type ]);
	}
}

void CChrItem::OnDelete()
{
	if( !RIGHT(MASK_18) )	return;

	CCharacterView* pView = (CCharacterView*)GetParent();
	if( MessageBox( "Do you want to Delete Item", "Delete", MB_YESNO ) != IDYES) return;

	for(int i=0; i<72; i++)
	{
		if(c_Inv[i].GetCheck())
		{
			CString szItemInfo;	int a,b,c;
			GetMatrix_inv(i,a,b,c);
			GetItemInfoByString( &pView->m_ChrInfoBinary.inv[a][b][c], szItemInfo.GetBuffer(0));
			

			//for extensionlog
			pView->m_pcLogMgr->CheckChrInfoBinary( "Delete", "Inventory", c_Inv[i].m_pAttr->item_no, szItemInfo.GetBuffer(0) );

			::SendMessage(c_Inv[i].m_hWnd,WM_SETTEXT,0,(LPARAM)"");
			memset(c_Inv[i].m_pAttr, 0, sizeof(c_Inv[i].m_pAttr));	//item 瘤快扁 
		}
	}

	//equip
	for(i=0; i<8; i++)
	{
		if(c_Equip[i].GetCheck())
		{
			CString szItemInfo;			
			GetItemInfoByString( &pView->m_ChrInfoBinary.equip[i], szItemInfo.GetBuffer(0));

			//for extensionlog
			pView->m_pcLogMgr->CheckChrInfoBinary( "Delete", "Equip", c_Equip[i].m_pAttr->item_no, szItemInfo.GetBuffer(0) );

			::SendMessage(c_Equip[i].m_hWnd,WM_SETTEXT,0,(LPARAM)"");
			memset(c_Equip[i].m_pAttr, 0, sizeof(c_Equip[i].m_pAttr));	//item 瘤快扁 
		}
	}

	//Quick
	for(i=0; i<6; i++)
	{
		if(c_Quick[i].GetCheck())
		{
			CString szItemInfo;			
			GetItemInfoByString( &pView->m_ChrInfoBinary.quick[i], szItemInfo.GetBuffer(0));

			//for extensionlog
			pView->m_pcLogMgr->CheckChrInfoBinary( "Delete", "Quick", c_Quick[i].m_pAttr->item_no, szItemInfo.GetBuffer(0) );

			::SendMessage(c_Quick[i].m_hWnd,WM_SETTEXT,0,(LPARAM)"");
			memset(c_Quick[i].m_pAttr, 0, sizeof(c_Quick[i].m_pAttr));	//item 瘤快扁 
		}
	}

	//Bank
	for(i=0; i<90; i++)
	{
		if(c_Bank[i].GetCheck())
		{
			CString szItemInfo;	int a,b,c;
			GetMatrix_bank(i,a,b,c);			
			GetItemInfoByString( &pView->m_ChrInfo2.bankitem[a][b][c], szItemInfo.GetBuffer(0));

			//for extensionlog
			pView->m_pcLogMgr->CheckChrInfoBinary( "Delete", "Bank", c_Bank[i].m_pAttr->item_no, szItemInfo.GetBuffer(0) );

			::SendMessage(c_Bank[i].m_hWnd,WM_SETTEXT,0,(LPARAM)"");
			memset(c_Bank[i].m_pAttr, 0, sizeof(c_Bank[i].m_pAttr));	//item 瘤快扁 
		}
	}


	//RefreshData();
	if(UpdateCurBinaryData())
		MessageBox("Deleted the Item!","OK");

	OnSelectClear();

}


void CChrItem::OnSave()
{
	if( !RIGHT(MASK_18) )	return;

	if( MessageBox( "Do you want to Save Items", "Save", MB_YESNO ) != IDYES) return;

	CCharacterView* pView;pView = (CCharacterView*)GetParent();
	UpdateData(TRUE);

	ItemAttr NewData;	memset(&NewData, 0, sizeof(NewData));
	int type, num;
	type = m_UpdateNo / 1000;
	num =  m_UpdateNo % 1000;

	if(CheckValidItem(type, num))	//蜡瓤茄 酒捞袍牢版快 
	{
		NewData.item_no  = (WORD)m_UpdateNo;		//酒捞袍 锅龋 

// BBD 0401116	酒贰 扁瓷篮 荤侩摹 臼绰促 蝶扼辑 昏力
/*
#ifdef FIND_TREASURE
// 030715 kyo <<
	if( LOW_LEVEL_MAP <= NewData.item_no  && TREASURE_BOX >= NewData.item_no )
	{
		NewData.attr[IATTR_RESERVED0] = 0;
		//CTreasureMapItem *pAttr = reinterpret_cast<CTreasureMapItem*>(&NewData.attr[IATTR_RESERVED0]);
		CTreasureMapItem *pAttr = (CTreasureMapItem*)(&NewData.attr[IATTR_RESERVED0]);
		pAttr->first = 1;
	}

//>>
#endif
*/
		if( m_MuchMax !=0 )
		{
			if(m_MuchNow > m_MuchMax)
			{
				MessageBox("Confirm the maximum of durability");
				return ;
			}
			NewData.attr[IATTR_DURATION] = MAKELONG(m_MuchNow,m_MuchMax);
		}
		else 
			NewData.attr[IATTR_MUCH] = m_MuchNow;

		NewData.attr[IATTR_LIMIT] = m_UpdateLimit;
		NewData.attr[IATTR_SOKSUNG] = AddSoksung();	//this sok lsw
	}
	else
		return;

	CString szItemInfo;
	szItemInfo.Format( "Limit:%d@Type:%s@Now:%d@Max:%d@Grade:%d@Kind1:%d@Kind2:%d@Kind3:%d@High:%d@IsFunc:%d",
		m_UpdateLimit, m_MuchType, m_MuchNow, m_MuchMax, m_MutantGrade, m_MutantKind1,m_MutantKind2,m_MutantKind3, m_iHighLevel, m_bIsDynamic );
	/*
	m_MuchNow/m_MuchMax
	m_UpdateLimit
	m_MutantGrade;
	m_MutantKind1;
	m_MutantKind2;
	m_MutantKind3;
	m_iHighLevel;	
	m_bIsDynamic;	
	*/
	
	char szTemp[ 10 ];	
	//inv
	for(int i=0; i<72; i++)
	{
		if(c_Inv[i].GetCheck())
		{
			//CheckChrInfoBinary( const char* func, const char *type, const int& iValue, const char* tmp)
			//for Extensionlog
			//pView->m_pcLogMgr->CheckChrInfoBinary( "Save", "inventory", c_Inv[i].m_pAttr->item_no, szItemInfo.GetBuffer(0) );
			pView->m_pcLogMgr->CheckChrInfoBinary( "Save", "inventory", m_UpdateNo, szItemInfo.GetBuffer(0) );

			memcpy(c_Inv[i].m_pAttr, &NewData, sizeof(NewData));
			::SendMessage(c_Inv[i].m_hWnd, WM_SETTEXT, 0, (LPARAM)_itoa(c_Inv[i].m_pAttr->item_no, szTemp, 10));
		}
	}

	//equip
	for(i=0; i<8; i++)
	{
		if(c_Equip[i].GetCheck())
		{
			//for Extensionlog
			pView->m_pcLogMgr->CheckChrInfoBinary( "Save", "Equip", c_Equip[i].m_pAttr->item_no, szItemInfo.GetBuffer(0) );

			memcpy(c_Equip[i].m_pAttr, &NewData, sizeof(NewData));
			::SendMessage(c_Equip[i].m_hWnd, WM_SETTEXT, 0, (LPARAM)_itoa(c_Equip[i].m_pAttr->item_no, szTemp, 10));
		}
	}

	//Quick
	for(i=0; i<6; i++)
	{
		if(c_Quick[i].GetCheck())
		{
			if( 5 == i ) // DualEvent Item
			{
				NewData.attr[IATTR_DURATION] = m_iDualSymbolGrade;
			}
			//for Extensionlog
			pView->m_pcLogMgr->CheckChrInfoBinary( "Save", "Quick", c_Quick[i].m_pAttr->item_no, szItemInfo.GetBuffer(0) );

			memcpy(c_Quick[i].m_pAttr, &NewData, sizeof(NewData));
			::SendMessage(c_Quick[i].m_hWnd, WM_SETTEXT, 0, (LPARAM)_itoa(c_Quick[i].m_pAttr->item_no, szTemp, 10));
		}
	}

	//Bank
	for(i=0; i<90; i++)
	{
		if(c_Bank[i].GetCheck())
		{
			//for Extensionlog
			pView->m_pcLogMgr->CheckChrInfoBinary( "Save", "Bank", c_Bank[i].m_pAttr->item_no, szItemInfo.GetBuffer(0) );

			memcpy(c_Bank[i].m_pAttr, &NewData, sizeof(NewData));
			::SendMessage(c_Bank[i].m_hWnd, WM_SETTEXT, 0, (LPARAM)_itoa(c_Bank[i].m_pAttr->item_no, szTemp, 10));
		}
	}

	if(UpdateCurBinaryData())
		MessageBox("Saved!","OK");

	OnSelectClear();

#ifdef RM_LOG_MODE
	CString str;	str.Format("CChrBasic :: Saved item info(%s)",pView->m_szCurCharName);
	m_pApp->LogChar(pView->m_nCurServerSet, str);
#endif

}

void CChrItem::OnSelectClear()
{
	//if(RIGHT(1000) || RIGHT(10))	return;

	for(int i=0; i<72; i++)
	{
		if(c_Inv[i].GetCheck())
			c_Inv[i].SetCheck(FALSE);
	}

	//equip
	for(i=0; i<8; i++)
	{
		if(c_Equip[i].GetCheck())
			c_Equip[i].SetCheck(FALSE);
		
	}

	//Quick
	for(i=0; i<6; i++)
	{
		if(c_Quick[i].GetCheck())
			c_Quick[i].SetCheck(FALSE);
	}

	//Bank
	for(i=0; i<90; i++)
	{
		if(c_Bank[i].GetCheck())
			c_Bank[i].SetCheck(FALSE);
	}
}

DWORD CChrItem::AddSoksung()//020925 lsw
{
	t_RareMain Rare;

	Rare.grade			=	m_MutantGrade;
	Rare.soksung1		=	m_MutantKind1;
	Rare.soksung2		=	m_MutantKind2;
	Rare.soksung3		=	m_MutantKind3;
	Rare.HighLevel		=	m_iHighLevel;		
	Rare.IsDynamicRare	=	m_bIsDynamic;	
	DWORD sok = 0;
	memcpy(&sok,&Rare,sizeof(DWORD) );
	return sok;
}

BOOL CChrItem::UpdateCurBinaryData()
{
	CCharacterView* pView = (CCharacterView*)GetParent(); 

		
	if( strcmp(g_CurDbName[ pView->m_nCurDbIndex ], g_NationAccount.szDragon_DB_DefaultName[pView->m_nCurDbIndex]) )
	//if( strcmp(g_CurDbName[ pView->m_nCurDbIndex ], DEFAULT_GAME_DB) )
	{
		MessageBox("Don't Change In Backup DB Data!");
		return FALSE;
	}
	
	//Update 巩 
	char szQuery[ 1024 ];
	WCHAR wszQuery[ 1024 ];
	
	sprintf(szQuery, "Update chr_info set inventory=?, equip=?, quick=? "
					"where [name]='%s'",pView->m_szCurCharName);

	int nColumn = 3;
	DWORD	dwParamOffset = 0;	
	DBBINDING* pBinding = g_pDb->CreateParamInfo((BYTE)nColumn);	if(!pBinding) { MessageBox("Failed CreateParamInfo");	return 0;	}

	pBinding[0].obValue = dwParamOffset;	
	pBinding[0].cbMaxLen = sizeof(pView->m_ChrInfoBinary.inv);
	pBinding[0].wType = DBTYPE_BYTES;
	dwParamOffset += sizeof(pView->m_ChrInfoBinary.inv);

	pBinding[1].obValue = dwParamOffset;	
	pBinding[1].cbMaxLen = sizeof(pView->m_ChrInfoBinary.equip);
	pBinding[1].wType = DBTYPE_BYTES;
	dwParamOffset += sizeof(pView->m_ChrInfoBinary.equip);

	pBinding[2].obValue = dwParamOffset;	
	pBinding[2].cbMaxLen = sizeof(pView->m_ChrInfoBinary.quick);
	pBinding[2].wType = DBTYPE_BYTES;
	dwParamOffset += sizeof(pView->m_ChrInfoBinary.quick);

	g_pDb->KSCToUnicode(szQuery,wszQuery);
	int ret = g_pDb->ExecuteSQLByParam(wszQuery, pBinding, &pView->m_ChrInfoBinary, (BYTE)nColumn, (BYTE)CON);
	
	if(!ret)
	{
		MessageBox("Have no Character!");
		return 0;
	}
	else if(ret < 0)
	{
		MessageBox("fail to update chr_info_binary!");
		return 0;
	}

	g_pDb->ReleaseParamInfo(pBinding, (BYTE)CON);
	
	
	//chr_info2 历厘 
	nColumn = 1;
	dwParamOffset = 0;
	pBinding = g_pDb->CreateParamInfo( (BYTE)nColumn);	if(!pBinding) { MessageBox("Failed CreateParamInfo");	return 0;	}
	
	pBinding[0].obValue = dwParamOffset;	
	pBinding[0].cbMaxLen = sizeof(pView->m_ChrInfo2.bankitem);
	pBinding[0].wType = DBTYPE_BYTES;
	dwParamOffset += sizeof(pView->m_ChrInfo2.bankitem);

	sprintf(szQuery, "Update chr_info2 set bankitem=? where [name]='%s'",pView->m_szCurCharName);
	
	g_pDb->KSCToUnicode(szQuery,wszQuery);
	ret = g_pDb->ExecuteSQLByParam(wszQuery, pBinding, &pView->m_ChrInfo2, (BYTE)nColumn, (BYTE)CON);
	
	if(!ret)
	{
		MessageBox("Have no Character!");
		return 0;
	}
	else if(ret < 0)
	{
		MessageBox("fail to update chr_info2!");
		return 0;
	}
	
	g_pDb->ReleaseParamInfo(pBinding, (BYTE)CON);

	//for ExtensionLog
	WriteLog();

	return TRUE;
}

void CChrItem::OnSetfocusUpdateNo() 
{
	// TODO: Add your control notification handler code here
	SetDlgItemText(IDC_UPDATE_HAN_NAME, "");
	SetDlgItemText(IDC_UPDATE_TYPE, "");
}

void CChrItem::SelectClear()
{
	OnSelectClear();
}

void CChrItem::OnItemSearch() 
{
	// TODO: Add your control notification handler code here
	OnSelectClear();
	UpdateData(TRUE );
	CString szTmp;
	if( m_UpdateNo <=0 ) return;

	szTmp.Format( "%d", m_UpdateNo );

	ItemSearch( szTmp );
}

void CChrItem::ItemSearch( CString &rString )
{
	CString tmp;
	for(int i=0; i<72; i++)
	{
		c_Inv[i].GetWindowText( tmp);
		if( !rString.Compare( tmp ) )			
			c_Inv[i].SetCheck(TRUE);
	}

	//equip
	for(i=0; i<8; i++)
	{
		c_Equip[i].GetWindowText( tmp);
		if( !rString.Compare( tmp ) )
			c_Equip[i].SetCheck(TRUE);
	}

	//Quick
	for(i=0; i<6; i++)
	{
		c_Quick[i].GetWindowText( tmp);
		if( !rString.Compare( tmp ) )
			c_Quick[i].SetCheck(TRUE);
	}

	//Bank
	for(i=0; i<90; i++)
	{
		c_Bank[i].GetWindowText( tmp);
		if( !rString.Compare( tmp ) )
			c_Bank[i].SetCheck(TRUE);
	}		
}

void CChrItem::OnCheckMulti() 
{
	// TODO: Add your control notification handler code here
	OnSelectClear();	
}

void CChrItem::GetItemInfoByString( ItemAttr *work, char* szItemInfo)
{//SetItemView客 度鞍篮 备炼

	//酒捞袍沥焊甫 抛捞喉狼 tmp俊 历厘窍绰 屈侥栏肺 持绢霖促. 
	//"Limit:%d@Type:%s@Now:%d@Max:%d@Grade:%d@Kind1:%d@Kind2:%d@Kind3:%d@High:%d@IsFunc:%d"
	//m_UpdateLimit, m_MuchType, m_MuchNow, m_MuchMax, m_MutantGrade, m_MutantGrade, m_MutantKind1,m_MutantKind2,m_MutantKind3, m_iHighLevel, m_bIsDynamic );

	_ASSERTE (szItemInfo != NULL );

	CCharacterView* pView = (CCharacterView*)GetParent();
	
	DWORD dwUpdateLimit, dwMuchNow, dwMuchMax, dwMutantGrade, dwMutantKind1, dwMutantKind2, dwMutantKind3, dwHighLevel, dwIsDynamic;
	CString szMuchType;

	int type, num;
	GetItemIndex( work->item_no, type, num );
	
	if(CheckValidItem(type, num))	//蜡瓤茄 酒捞袍牢版快 
	{
		m_pSelectItemAttr = work;
		UpdateData(TRUE);
		
		ItemData51* pData = GetItemPointer(	pView->m_nCurServerSet , type, num );

		//char *type_to_name[11] = {	"PLANT", "MINERAL", "HERB", "COOK", "POTION", "TOOL", 
		//								"WEAPON", "DISPOSABLE", "ARMOR", "ACCESSORY", "ETC" };

		//m_UpdateHanName = pData->han_name;
		//m_UpdateType = type_to_name[ type ];
		//m_UpdateNo = work->item_no;

		if(pData->mouse_mr == 3)
		{
			//SetDlgItemText(IDC_MUCH_TYPE, "MUCH");					//Type阑 Much肺 悸泼 
			szMuchType = "MUCH";
			//SetDlgItemInt(IDC_MUCH_NOW, work->attr[IATTR_MUCH]);	//MUCH_MAX 蔼 悸泼 
			dwMuchNow = work->attr[IATTR_MUCH];
			//SetDlgItemInt(IDC_MUCH_MAX, 0);							//MUCH_NOW 蔼 悸泼 
			dwMuchMax = work->attr[IATTR_MUCH];
		}
		else
		{
			//SetDlgItemText(IDC_MUCH_TYPE, "DURATION");				//Type阑 DURATION栏肺悸泼 
			szMuchType = "DURATION";
			//SetDlgItemInt(IDC_MUCH_NOW, LOWORD( work->attr[IATTR_DURATION] ));	//curr 扁埃 泅犁 蔼
			dwMuchNow = LOWORD( work->attr[IATTR_DURATION] );
			//SetDlgItemInt(IDC_MUCH_MAX, HIWORD( work->attr[IATTR_DURATION] ));	//max 扁埃 钙胶蔼						//MUCH_NOW 蔼 悸泼 
			dwMuchMax = HIWORD( work->attr[IATTR_DURATION] );
		}

		
		//SetDlgItemInt(IDC_LIMIT, work->attr[IATTR_LIMIT]);	//Limit Number
		dwUpdateLimit = work->attr[IATTR_LIMIT];
		ConvertLimit(dwUpdateLimit);//020303 lsw

		t_RareMain SokSung_work;
				
		memcpy(&SokSung_work,&work->attr[IATTR_SOKSUNG],4);

		dwMutantGrade = SokSung_work.grade;
		dwMutantKind1 = SokSung_work.soksung1;
		dwMutantKind2 = SokSung_work.soksung2;
		dwMutantKind3 = SokSung_work.soksung3;
		dwHighLevel  = SokSung_work.HighLevel;	// 021128
		dwIsDynamic  = SokSung_work.IsDynamicRare;	// 021128

		//UpdateData(FALSE);
		sprintf( szItemInfo, "Limit:%d@Type:%s@Now:%d@Max:%d@Grade:%d@Kind1:%d@Kind2:%d@Kind3:%d@High:%d@IsFunc:%d", 
				m_UpdateLimit, szMuchType, dwMuchNow, dwMuchMax, dwMutantGrade, dwMutantKind1, dwMutantKind2, dwMutantKind3, dwHighLevel, dwIsDynamic );
		
	}
	else
	{
		
	}
	
}

void CChrItem::GetMatrix_inv( const int i, int& a, int& b, int& c)
{//338
	a = i/24 ;
	b = i%24 / 8;
	c = (i%24)%8;
}

void CChrItem::GetMatrix_bank( const int i, int& a, int& b, int& c)
{
	//536
	a = i/18 ;
	b = i%18 / 6;
	c = (i%18)%6;
}

void CChrItem::WriteLog()
{	//角力肺 肺弊 巢扁绰 何盒篮 酒捞袍狼 困摹俊 蝶扼 崔扼瘤扁 锭巩俊 
	//捞镑俊辑绰 扁粮 郴侩狼 丹绢静扁父 角青茄促. 

	CCharacterView *pView = (CCharacterView*)GetParent();
	
	if( pView->m_pcLogMgr == NULL)
	{
		MessageBoxPrintf( MB_OK, "NULL CLogMgr In Item" );
		return;
	}
	
	pView->m_pcLogMgr->SetChrInfo_Item( pView->m_ChrInfoBinary );		//官诧吧肺 update茄促

}

BOOL CChrItem::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -