示例#1
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageViewFill,enMode_Spread);
	DrawViewImage(pDC,m_ImageViewBack,enMode_Centent);

	//绘画用户
	TCHAR szBuffer[64]=TEXT("");
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);
		//test
		//WORD wUserTimer = 30;
		//tagUserData *pUserData = new tagUserData;
		//lstrcpy(pUserData->szName,TEXT("测试玩家"));
		//pUserData->lScore = 10000L;
		//pUserData->cbUserStatus = US_READY;

		//绘画用户
		if (pUserData!=NULL)
		{
			//用户名字
			pDC->SetTextAlign(((i==0)||(i==1))?TA_RIGHT:TA_LEFT);
			DrawTextString(pDC,pUserData->szName,RGB(255,255,255),RGB(0,0,0),m_ptName[i].x,m_ptName[i].y);

			//用户金币
			LONG lLeaveScore=pUserData->lScore-((pUserData->cbUserStatus==US_PLAY)?m_lTableScore[i]:0);
			_snprintf(szBuffer,CountArray(szBuffer),TEXT("%ld"),lLeaveScore);
			DrawTextString(pDC,szBuffer,RGB(255,255,255),RGB(0,0,0),m_ptName[i].x,m_ptName[i].y+16);
			//当前下注
			if( m_lTableScore[i] > 0L )
			{
				if( i == 2 ) pDC->SetTextAlign(TA_RIGHT);
				_snprintf(szBuffer,CountArray(szBuffer),TEXT("已下注%ld"),m_lTableScore[i]);
				DrawTextString(pDC,szBuffer,RGB(255,255,255),RGB(0,0,0),m_ptTableScore[i].x,m_ptTableScore[i].y);
			}

			//其他信息
			if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
		}
		//delete pUserData;

		//玩家筹码
		m_PlayerJeton[i].DrawJettonControl(pDC);
		//筹码数字
		LONG lJetonScore = m_PlayerJeton[i].GetScore();
		if( lJetonScore > 0L )
		{
			CPoint pt = m_PlayerJeton[i].GetBenchmarkPos();
			CRect rcDraw(pt.x-50,pt.y+15,pt.x+50,pt.y+27);
			_snprintf(szBuffer,CountArray(szBuffer),TEXT("%ld"),lJetonScore);
			pDC->SetTextAlign(TA_LEFT);
			DrawTextString(pDC,szBuffer,RGB(255,255,85),RGB(0,0,0),&rcDraw);
		}
	}
	m_PlayerJeton[GAME_PLAYER].DrawJettonControl(pDC);

	//绘画扑克
	if (m_SendCardItemArray.GetCount()>0)
	{
		//变量定义
		CImageHandle HandleCard(&m_ImageCard);
		tagSendCardItem * pSendCardItem=&m_SendCardItemArray[0];

		//获取大小
		int nItemWidth=m_ImageCard.GetWidth()/13;
		int nItemHeight=m_ImageCard.GetHeight()/5;

		//绘画扑克
		m_ImageCard.AlphaDrawImage(pDC,m_SendCardCurPos.x,m_SendCardCurPos.y,nItemWidth,nItemHeight,nItemWidth*2,nItemHeight*4,RGB(255,0,255));
	}
	//test
	//CImageHandle HandleCard(&m_ImageCard);
	//m_ImageCard.AlphaDrawImage(pDC,m_SendCardPos.x,m_SendCardPos.y,m_ImageCard.GetWidth()/13,m_ImageCard.GetHeight()/5,
	//	m_ImageCard.GetWidth()/13*2,m_ImageCard.GetHeight()/5*4,RGB(255,0,255));

	INT nNumberWidth = m_PngNumber.GetWidth()/10;
	INT nNumberHeight = m_PngNumber.GetHeight();
	//底注信息
	if( m_lCellScore > 0L )
	{
		INT nXPos;
		INT nYPos = nHeight/2-325;
		int nCellCount = 0;
		BYTE byCell[10];
		LONG lCellScore = m_lCellScore;
		while( lCellScore > 0L )
		{
			byCell[nCellCount++] = (BYTE)(lCellScore-lCellScore/10*10);
			lCellScore /= 10;
			if( nCellCount == 10 ) break;
		}
		nXPos = nWidth/2-200-nCellCount*nNumberWidth/2;
		for( int j = nCellCount-1; j >= 0; j-- )
		{
			m_PngNumber.DrawImage(pDC,nXPos,nYPos,nNumberWidth,nNumberHeight,byCell[j]*nNumberWidth,0);
			nXPos += nNumberWidth;
		}
	}
	//计算总注
	LONG lTableScore=0L;
	//注:包括正在下注在内
	for(int i = 0; i < GAME_PLAYER; i++ )
		lTableScore += m_PlayerJeton[i].GetScore();
	lTableScore+=m_PlayerJeton[GAME_PLAYER].GetScore();
	//test
	//lTableScore = 1234567L;
	//总注信息
	if (lTableScore>0L)
	{
		INT nXPos = nWidth/2+18;
		INT nYPos = nHeight/2-295;
		int nCellCount = 0;
		BYTE byCell[10];
		while( lTableScore > 0L )
		{
			byCell[nCellCount++] = (BYTE)(lTableScore-lTableScore/10*10);
			lTableScore /= 10;
			if( nCellCount == 10 ) break;
		}
		for( int j = nCellCount-1; j >= 0; j-- )
		{
			m_PngNumber.DrawImage(pDC,nXPos,nYPos,nNumberWidth,nNumberHeight,byCell[j]*nNumberWidth,0);
			nXPos += nNumberWidth;
		}
	}

	return;
}
示例#2
0
//显示倍数
void CGameClientView::DrawLandTime(CDC *pDC, INT nViewWidth, INT nViewHeight)
{
	//图片信息
	INT nDigitWidth = m_ImageLandTimes.GetWidth() / 11;
	INT nDigitHeight = m_ImageLandTimes.GetHeight();

	//设置变量
	bool bBrightStart = false;
	for ( WORD wChairID = 0; wChairID < GAME_PLAYER; ++wChairID )
	{
		//存在判断
		tagUserData const *pUserData = GetUserInfo( wChairID );
		if ( pUserData == NULL )  m_bBrightStart[wChairID] = false;
	}
	for ( WORD wChairID = 0; wChairID < GAME_PLAYER; ++wChairID )
		if ( m_bBrightStart[wChairID] ) bBrightStart = true;

	//重置变量
	WORD wCardCount = m_bCardCount[0] + m_bCardCount[1] + m_bCardCount[2];
	if ( ! bBrightStart && wCardCount == 0 ) m_cbBrightTime = 0;

	//翻倍计算
	WORD wDrawTimes=(WORD)m_lBaseScore;
	for (WORD i=1;i<m_cbLandScore;i++) wDrawTimes*=2;

	//总共倍数
	WORD wLandTime = 0;
	if ( m_cbBrightTime != 0 && wDrawTimes == 0 ) wLandTime = m_cbBrightTime;
	else if ( m_cbBrightTime == 0 && wDrawTimes != 0 ) wLandTime = wDrawTimes;
	else if ( m_cbBrightTime != 0 && wDrawTimes != 0 ) wLandTime = m_cbBrightTime * wDrawTimes;

	//大小过滤
	if ( wLandTime <= m_lBaseScore ) return ;

	//数字个数
	INT nDigitCount = 0;
	INT nTmpTime = wLandTime;
	while( 1 <= nTmpTime )
	{
		nDigitCount++;
		nTmpTime /= 10;
	}

	if ( 1 <= nDigitCount )
	{
		//总共长度
		INT nTotalLen = ( nDigitCount +1 ) * nDigitWidth;

		//位置信息
		INT nXPos = 0; 
		INT nYPos = 0;

		nXPos = ( nViewWidth - nTotalLen ) / 2 ;
		nYPos = 150;

		//绘画乘号
		m_ImageLandTimes.DrawImage(pDC, nXPos, nYPos, nDigitWidth, nDigitHeight, 10 * nDigitWidth, 0);

		//开始绘画
		while( 0 < nDigitCount )
		{
			//计算位置
			nXPos += nDigitWidth;

			//计算倍数
			--nDigitCount;
			INT nMutiple = (INT)pow( 10, nDigitCount );

			//绘画数字
			INT nDrawDigit = (INT)(wLandTime / nMutiple) ;
			m_ImageLandTimes.DrawImage(pDC, nXPos, nYPos, nDigitWidth, nDigitHeight, nDrawDigit * nDigitWidth, 0);

			//计算变量
			wLandTime -= ( nMutiple * nDrawDigit );
		}
	}
}
示例#3
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//地震效果
	if(m_bFalsh)
	{
		CImageHandle ImageHandleBack(&m_ImageViewBack);
		int xValue=rand()%ROCK;
		int yValue=rand()%ROCK;
		if(xValue%2==0)xValue*=(-1);
		if(yValue%2==0)yValue*=(-1);
		m_ImageViewBack.AlphaDrawImage(pDC,(nWidth/2-512)+xValue,(nHeight/2-397)+yValue,
			m_ImageViewBack.GetWidth(),m_ImageViewBack.GetHeight(),0,0,RGB(255,0,255));
	}
	else 
	{
		CImageHandle ImageHandleBack(&m_ImageViewBack);
		m_ImageViewBack.AlphaDrawImage(pDC,(nWidth/2-512+6),(nHeight/2-383),
			m_ImageViewBack.GetWidth(),m_ImageViewBack.GetHeight(),0,0,RGB(255,0,255));

		//绘画背景
		//DrawViewImage(pDC,m_ImageViewCenter,enMode_Spread);//用于最大化窗口
		//DrawViewImage(pDC,m_ImageViewBack,enMode_Centent);
	}

	if(!m_bStopDraw)
	{
		//绘画用户
		for (WORD i=0;i<GAME_PLAYER;i++)
		{
			//变量定义
			WORD wUserTimer=GetUserTimer(i);
			const tagUserData * pUserData=GetUserInfo(i);

#ifdef _DEBUG
			////测试代码
			//tagUserData Obj;
			//Obj.cbGender = 1;
			//_sntprintf(Obj.szName,sizeof(Obj.szName),TEXT("用户的名字"));
			//Obj.cbUserStatus=US_READY;
			////Obj.wFaceID = 2;
			//pUserData = &Obj;

			////庄家标志
			//CImageHandle ImageHandleBanker(&m_ImageBanker);
			//m_ImageBanker.AlphaDrawImage(pDC,m_PointBanker[i].x,m_PointBanker[i].y,m_ImageBanker.GetWidth(),m_ImageBanker.GetHeight(),0,0,RGB(255,0,255));
#endif
			//绘画用户
			if (pUserData!=NULL)
			{
				//用户名字
				pDC->SetTextAlign(TA_CENTER);
				pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));
				DrawTextString(pDC,pUserData->szName,RGB(255,255,255),RGB(0,0,0),m_ptFace[i].x+15,m_ptFace[i].y+35);

				//用户金币
				TCHAR szBuffer[64]=TEXT("");
				LONG lLeaveScore=pUserData->lScore-((m_ScoreView.IsWindowVisible()==TRUE)?(0):(m_lTableScore[i]));//;
				if(m_lStopUpdataScore[i]>0)lLeaveScore=m_lStopUpdataScore[i]-m_lTableScore[i];
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("¥%ld"),lLeaveScore);
				DrawTextString(pDC,szBuffer,RGB(255,255,255),RGB(0,0,0),m_ptFace[i].x+10,m_ptFace[i].y+48);

				//其他信息
				//wUserTimer =1;
				if (wUserTimer!=0) 
				{
					if(m_CardControl[MY_SELF_CHAIRID].GetCardCount()==0)
						DrawUserTimer(pDC,m_ptFace[i].x+m_nXFace/2,m_ptTimer[i].y+90,wUserTimer);
					else DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
				}

				//准备标志
				if (pUserData->cbUserStatus==US_READY) 
				{
					DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
				}
				DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
			}
		}

		//计算总注
		LONG lTableScore=0L;
		for (WORD i=0;i<GAME_PLAYER;i++) lTableScore+=m_lTableScore[i];

		//总注信息
		if (lTableScore>0L)
		{	
			CImageHandle ImageHandle3(&m_ImageNumber);
			int iCount=0;
			LONG lCell[11];
			ZeroMemory(lCell,sizeof(lCell));
			while(lTableScore>0L)
			{
				LONG lScore=lTableScore%10;
				lCell[iCount++] = lScore;
				lTableScore=lTableScore/10;
			}
			int iTemp=0;
			int iX=m_ImageNumber.GetWidth();
			for (int i=iCount-1;i>=0;i--)
			{
				m_ImageNumber.AlphaDrawImage(pDC,nWidth/2+39+(iX/10)*(iTemp++),nHeight/2-296,
					iX/10,m_ImageNumber.GetHeight(),iX/10*lCell[i],0,RGB(255,0,255));
			}
		}

		//庄家信息
		if (m_wBankerUser!=INVALID_CHAIR)
		{
			//庄家标志
			CImageHandle ImageHandleBanker(&m_ImageBanker);
			m_ImageBanker.AlphaDrawImage(pDC,m_PointBanker[m_wBankerUser].x,m_PointBanker[m_wBankerUser].y,m_ImageBanker.GetWidth(),m_ImageBanker.GetHeight(),0,0,RGB(255,0,255));
		}

		//不存在个数
		for (BYTE i=0;i<GAME_PLAYER;i++)	
		{
			//绘画判断
			//m_lCurrentScore[i] = 100000;
			if (m_lCurrentScore[i]==0L) continue;
			LONG lTemp=m_lCurrentScore[i];
			LONG lTimes[]={10,20,50,100,200,500,1000,2000,5000,10000,20000,50000,100000,200000,500000};
			for (BYTE k=CountArray(lTimes)-1;;k--)
			{
				if(lTemp>=lTimes[k])
				{
					//绘画信息
					tagGoldMes tagTemp;
					tagTemp.lDrawCount = (lTemp/lTimes[k]);
					tagTemp.lGoldType = k;
					m_lDrawGold[i].Add(tagTemp);

					while((tagTemp.lDrawCount--)>0)
					{
						//随机位置
						int xTemp=rand();
						int yTemp=rand();
						int bRandX=nWidth/2-25+xTemp%60*((xTemp%2==0)?1:(-1));
						int bRandY=nHeight/2-70+yTemp%60*((yTemp%2==0)?1:(-1));

						//保存随机位置
						CPoint ptTemp;
						ptTemp.SetPoint(bRandX,bRandY);
						m_ptKeepJeton[i].Add(ptTemp);
					}

					lTemp%=lTimes[k];
					if(lTemp==0)break;
				}
			}
			m_lCurrentScore[i]=0L;
		}

		//绘画筹码
		for (BYTE i=0;i<GAME_PLAYER;i++)
		{
			//m_lTableScore[i] = 100000;
			if (m_lTableScore[i]==0L ) continue;
			CImageHandle HandleJeton(&m_ImageJeton);

			//固定位置输出
			int Count=0;
			for(int j=0;j<(m_lDrawGold[i].GetCount());j++)
			{
				LONG lDrawCount = m_lDrawGold[i].GetAt(j).lDrawCount;
				while((lDrawCount--)>0)
				{
					CPoint cpTemp=m_ptKeepJeton[i].GetAt(Count++);
					m_ImageJeton.AlphaDrawImage(pDC,cpTemp.x,cpTemp.y,m_ImageJeton.GetWidth()/15,
						m_ImageJeton.GetHeight(),m_ImageJeton.GetWidth()/15*(m_lDrawGold[i].GetAt(j).lGoldType),0,RGB(255,0,255));
					if(Count==100)break;
				}
				if(Count==100)break;
			}

			//绘画数目
			TCHAR szBuffer[64];
			_snprintf(szBuffer,CountArray(szBuffer),TEXT("$:%ld"),m_lTableScore[i]);

			//计算位置
			CRect rcDrawRect;
			rcDrawRect.top=m_CardControl[i].GetCardPos().y;
			rcDrawRect.left=m_CardControl[i].GetCardPos().x+((i>2)?(135):(-50));
			rcDrawRect.right=rcDrawRect.left+30;
			rcDrawRect.bottom=rcDrawRect.top+12;

			//创建字体
			CFont ViewFont;
			ViewFont.CreateFont(-14,0,0,0,700,0,0,0,134,3,2,1,2,TEXT("宋体"));

			//设置字体
			CFont * pOldFont=pDC->SelectObject(&ViewFont);

			//绘画数目
			pDC->SetTextAlign(TA_LEFT);
			pDC->SetTextColor(RGB(250,200,40));
			pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcDrawRect,DT_CENTER|DT_VCENTER|DT_NOCLIP|DT_SINGLELINE);

			//清理字体
			pDC->SelectObject(pOldFont);
		}

		//绘画信息
		if(m_lCellScore>0)
		{
			//创建字体
			CFont ViewFont;
			ViewFont.CreateFont(-12,0,0,0,700,0,0,0,134,3,2,1,2,TEXT("宋体"));

			//设置字体
			CFont * pOldFont=pDC->SelectObject(&ViewFont);

			pDC->SetTextAlign(TA_LEFT);
			pDC->SetTextColor(RGB(0,0,0));

			//计算位置
			CRect rcDrawRect;

			//绘画数目
			TCHAR szBuffer[64];
			_snprintf(szBuffer,CountArray(szBuffer),TEXT("封顶:%ld"),m_lMaxCellScore);
			rcDrawRect.top=nHeight/2-338;
			rcDrawRect.left=nWidth/2-233;
			rcDrawRect.right=rcDrawRect.left+50;
			rcDrawRect.bottom=rcDrawRect.top+12;
			pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcDrawRect,DT_CENTER|DT_VCENTER|DT_NOCLIP|DT_SINGLELINE);

			_snprintf(szBuffer,CountArray(szBuffer),TEXT("单注:%ld"),m_lCellScore);
			rcDrawRect.top=nHeight/2-318;
			rcDrawRect.left=nWidth/2-230;
			rcDrawRect.right=rcDrawRect.left+50;
			rcDrawRect.bottom=rcDrawRect.top+12;
			pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcDrawRect,DT_CENTER|DT_VCENTER|DT_NOCLIP|DT_SINGLELINE);

			//清理字体
			pDC->SelectObject(pOldFont);		
		}

		//选比标志
		if(m_bCompareCard)
		{
			for (int i=0;i<GAME_PLAYER;i++)
			{
				if(m_bCompareUser[i]==TRUE)
				{
					CPoint cPost=m_CardControl[i].GetCardPos();
					CImageHandle ImageArrowhead(&m_ImageArrowhead);
					m_ImageArrowhead.AlphaDrawImage(pDC,cPost.x,cPost.y-m_ImageArrowhead.GetHeight(),
						m_ImageArrowhead.GetWidth(),m_ImageArrowhead.GetHeight(),0,0,RGB(255,0,255));
				}
			}
		}
	}

	//发牌绘画
	if (m_SendCardItemArray.GetCount()>0)
	{
		//变量定义
		CImageHandle HandleCard(&m_ImageCard);
		tagSendCardItem * pSendCardItem=&m_SendCardItemArray[0];

		//获取大小
		int nItemWidth=m_ImageCard.GetWidth()/13;
		int nItemHeight=m_ImageCard.GetHeight()/5;

		//绘画扑克
		int nXPos=m_SendCardPos.x-nItemWidth/2;
		int nYPos=m_SendCardPos.y-nItemHeight/2+10;
		m_ImageCard.AlphaDrawImage(pDC,nXPos,nYPos,nItemWidth,nItemHeight,nItemWidth*2,nItemHeight*4,RGB(255,0,255));
	}

	//比牌扑克
	if (m_wLoserUser!=INVALID_CHAIR)
	{
		//送牌状态
		if (m_wConmareIndex<m_wConmareCount)
		{
			//绘画扑克
			for (BYTE i=0;i<2;i++)
			{
				//变量定义
				CPoint PointCard;
				CPoint PointStart=m_ptUserCard[m_wCompareChairID[i]];

				//计算位置
				INT nQuotiety=(i==0)?-1:1;
				PointCard.y=PointStart.y+(m_ptUserCompare.y-PointStart.y)*m_wConmareIndex/m_wConmareCount;
				PointCard.x=PointStart.x+(m_ptUserCompare.x-PointStart.x+COMPARE_RADII*nQuotiety)*m_wConmareIndex/m_wConmareCount;

				//绘画扑克
				DrawCompareCard(pDC,PointCard.x,PointCard.y,false);
			}
		}

		//比牌状态
		if ((m_wConmareIndex>=m_wConmareCount)&&((m_wConmareIndex<m_wConmareCount+VSCARD_COUNT*VSCARD_TIME)))
		{
			//绘画扑克
			for (BYTE i=0;i<2;i++)
			{
				//变量定义
				CPoint PointCard;
				CPoint PointStart=m_ptUserCard[m_wCompareChairID[i]];

				//计算位置
				INT nQuotiety=(i==0)?-1:1;
				PointCard.y=m_ptUserCompare.y;
				PointCard.x=m_ptUserCompare.x+COMPARE_RADII*nQuotiety;

				//绘画扑克
				DrawCompareCard(pDC,PointCard.x,PointCard.y,false);
			}

			//比牌标志
			CSize SizeVSCard;
			CPngImage ImageVSCard;
			ImageVSCard.LoadImage(AfxGetInstanceHandle(),TEXT("VS_CARD"));
			SizeVSCard.SetSize(ImageVSCard.GetWidth()/VSCARD_COUNT,ImageVSCard.GetHeight());

			//绘画标志
			INT nImageIndex=(m_wConmareIndex-m_wConmareCount)%VSCARD_COUNT;
			ImageVSCard.DrawImage(pDC,m_ptUserCompare.x-SizeVSCard.cx/2,m_ptUserCompare.y-SizeVSCard.cy/2,
				SizeVSCard.cx,SizeVSCard.cy,nImageIndex*SizeVSCard.cx,0);

			//声音效果
			CGameClientDlg * pGameClientDlg=CONTAINING_RECORD(this,CGameClientDlg,m_GameClientView);
			pGameClientDlg->PlayGameSound(AfxGetInstanceHandle(),TEXT("COMPARE_CARD"));

		}

		//回牌状态
		if (m_wConmareIndex>=m_wConmareCount+VSCARD_COUNT*VSCARD_TIME)
		{
			//变量定义
			WORD wConmareIndex=m_wConmareIndex-m_wConmareCount-VSCARD_COUNT*VSCARD_TIME;

			//绘画扑克
			for (BYTE i=0;i<2;i++)
			{
				//变量定义
				CPoint PointCard;
				CPoint PointStart=m_ptUserCard[m_wCompareChairID[i]];

				//计算位置
				INT nQuotiety=(i==0)?-1:1;
				PointCard.y=m_ptUserCompare.y+(PointStart.y-m_ptUserCompare.y)*wConmareIndex/m_wConmareCount;
				PointCard.x=m_ptUserCompare.x+COMPARE_RADII*nQuotiety+(PointStart.x-m_ptUserCompare.x-COMPARE_RADII*nQuotiety)*wConmareIndex/m_wConmareCount;

				//绘画扑克
				DrawCompareCard(pDC,PointCard.x,PointCard.y,(m_wLoserUser==m_wCompareChairID[i])?true:false);
			}

			//声音效果
			if(m_wConmareIndex==m_wConmareCount+VSCARD_COUNT*VSCARD_TIME)
			{
				CGameClientDlg * pGameClientDlg=CONTAINING_RECORD(this,CGameClientDlg,m_GameClientView);
				pGameClientDlg->PlayGameSound(AfxGetInstanceHandle(),TEXT("CENTER_SEND_CARD"));
			}
		}
	}

	//等待选择
	if(m_wWaitUserChoice!=INVALID_CHAIR)
	{
		TCHAR szBuffer[64]=TEXT("");

		//创建字体
		CFont ViewFont;
		ViewFont.CreateFont(-15,0,0,0,700,0,0,0,134,3,2,1,2,TEXT("宋体"));

		//设置字体
		CFont * pOldFont=pDC->SelectObject(&ViewFont);
		pDC->SetTextAlign(TA_CENTER);

		//输出信息
		if(m_wWaitUserChoice==TRUE)_sntprintf(szBuffer,sizeof(szBuffer),TEXT("等待玩家选择比牌"));
		else _sntprintf(szBuffer,sizeof(szBuffer),TEXT("请选择玩家进行比牌"));
		DrawTextString(pDC,szBuffer,RGB(50,50,50),RGB(0,170,0),nWidth/2+10,nHeight/2+45);

		//清理字体
		pDC->SelectObject(pOldFont);
	}

	return;
}
示例#4
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageBack,enMode_Spread);
	DrawViewImage(pDC,m_ImageCenter,enMode_Centent);

	//绘画用户
	TCHAR szBuffer[32];
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);

		/////////////////////////////////////////////////////

		//tagUserData *pUserData = new tagUserData;
		//strcpy( (char*)pUserData->szName, "dkjfdkfjdkfj" );
		//pUserData->cbUserStatus = US_READY;
		//wUserTimer = 10;
		//m_ImageLand.DrawImage(pDC,m_ptLand[i].x,m_ptLand[i].y);
		//m_wBombTime = 2;
		///////////////////////////////////////////////////////

		//绘画用户
		if (pUserData!=NULL)
		{
			//用户名字
			pDC->SetTextAlign( ( ( i == 2 && ! m_bDeasilOrder ) || ( i == 0 && m_bDeasilOrder ) ) ? TA_RIGHT : TA_LEFT );
			pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));
			DrawTextString( pDC, pUserData->szName, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_ptName[i].x,m_ptName[i].y );

			//剩余扑克
		//	if (i!=1)
			{
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("剩余:%d 张"),m_bCardCount[i]);
				DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_ptName[i].x,m_ptName[i].y+18 );
			}

			//其他信息
			if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
		}
	}

	//叫分标志
	int nXImagePos,nImageWidth=m_ImageScore.GetWidth(),nImageHeight=m_ImageScore.GetHeight();
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		if ((m_bScore[i]!=0)||(m_bPass[i]==true))
		{
			if ( m_bPass[i]==true ) nXImagePos=m_ImageScore.GetWidth()*4/5;
			else if ( m_bScore[i]==255 ) nXImagePos=m_ImageScore.GetWidth()*3/5;
			else nXImagePos=(m_bScore[i]-1)*m_ImageScore.GetWidth()/5;
			m_ImageScore.DrawImage(pDC,m_ptScore[i].x,m_ptScore[i].y,nImageWidth/5,nImageHeight,nXImagePos,0);
		}
	}

	//庄家位置
	if (m_wLandUser!=INVALID_CHAIR)
	{
		//获取用户
		const tagUserData * pUserData=GetUserInfo(m_wLandUser);
		if (pUserData!=NULL)
		{
			//变量定义
			TCHAR szBuffer[64];

			//设置 DC
			pDC->SetTextAlign(TA_LEFT|TA_TOP);
			pDC->SetTextColor(RGB(250,250,250));

			//绘画信息
			m_ImageLand.DrawImage(pDC,m_ptLand[m_wLandUser].x,m_ptLand[m_wLandUser].y);
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("地主:%s"),pUserData->szName);
			pDC->TextOut(m_nXBorder+m_nXFace+10,m_nYBorder+8,szBuffer,lstrlen(szBuffer));

			//绘画头像
			DrawUserFace(pDC,pUserData,m_nXBorder+5,m_nYBorder+5,false);

			//叫牌分数
			LONG lScore=m_cbLandScore*m_lBaseScore;
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("分数:%ld 分"),lScore);
			DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_nXBorder+m_nXFace+10,m_nYBorder+25 );
		}
	}

	//绘画爆炸
	if (m_bBombEffect==true)
	{
		//加载资源
		CImageHandle HandleBombEffect(&m_ImageBombEffect);

		//绘画效果
		INT nImageHeight=m_ImageBombEffect.GetHeight();
		INT nImageWidth=m_ImageBombEffect.GetWidth()/BOMB_EFFECT_COUNT;
		m_ImageBombEffect.AlphaDrawImage(pDC,(nWidth-nImageWidth)/2,0,nImageWidth,nImageHeight,
			nImageWidth*(m_cbBombFrameIndex%BOMB_EFFECT_COUNT),0,RGB(255,0,255));
	}

	//炸弹倍数
	if (m_wBombTime>1)
	{
		//炸弹标志
		CImageHandle ImageHandle(&m_ImageBomb);
		m_ImageBomb.AlphaDrawImage(pDC,m_nXBorder+5,nHeight-m_nYBorder-m_ImageBomb.GetHeight()-5,RGB(255,0,255));

		//设置 DC
		pDC->SetTextColor(RGB(250,250,250));
		pDC->SetTextAlign(TA_LEFT|TA_TOP);

		//炸弹倍数
		TCHAR szBuffer[64];
		_snprintf(szBuffer,sizeof(szBuffer),TEXT("炸弹翻倍:%d"),m_wBombTime);
		DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_nXBorder+m_ImageBomb.GetWidth()+10,nHeight-m_nYBorder-20 );
	//	pDC->TextOut(m_nXBorder+m_ImageBomb.GetWidth()+10,nHeight-m_nYBorder-20,szBuffer,lstrlen(szBuffer));
	}

	//描述信息
	if (m_bLandTitle==true)
	{
		//创建资源
		CFont InfoFont;
		InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

		//设置 DC
		pDC->SetTextColor(RGB(201,229,133));
		pDC->SetTextAlign(TA_CENTER|TA_TOP);
		CFont * pOldFont=pDC->SelectObject(&InfoFont);

		//绘画信息
		pDC->TextOut(nWidth/2,200,"正等待用户叫分");

		//清理资源
		pDC->SelectObject(pOldFont);
		InfoFont.DeleteObject();
	}

	//托管标识
	for ( WORD wChairID = 0; wChairID < GAME_PLAYER; ++wChairID ) {
		
		const tagUserData * pUserData=GetUserInfo( wChairID );
		if ( pUserData == NULL ) m_bUserTrustee[ wChairID ] = false;

		if ( m_bUserTrustee[ wChairID ] ) {
			if ( wChairID == 1 )
				m_ImageUserTrustee.DrawImage( pDC, m_ptLand[ wChairID ].x + 40, m_ptLand[ wChairID ].y - 1 );
			else
				m_ImageUserTrustee.DrawImage( pDC, m_ptLand[ wChairID ].x + 40, m_ptLand[ wChairID ].y - 1 );
		}
	}

	//历史积分
	if (m_bShowScore==true)
	{
		//积分背景
		CImageHandle HandleHistoryScore(&m_ImageHistoryScore);
		m_ImageHistoryScore.BitBlt(pDC->m_hDC,nWidth-m_ImageHistoryScore.GetWidth()-5,27);

		//计算位置
		INT nYBenchmark=27;
		INT nXBenchmark=nWidth-m_ImageHistoryScore.GetWidth()-5;
		UINT nFormat=DT_SINGLELINE|DT_END_ELLIPSIS|DT_VCENTER|DT_CENTER;

		//绘画属性
		pDC->SetTextAlign(TA_LEFT|TA_TOP);
		pDC->SetTextColor(RGB(254,247,137));

		//绘画信息
		for (WORD i=0;i<GAME_PLAYER;i++)
		{
			//获取用户
			const tagUserData * pUserData=GetUserInfo(i);
			if ((pUserData==NULL)||(m_pHistoryScore[i]==NULL)) continue;

			//位置计算
			CRect rcAccounts(nXBenchmark+2,nYBenchmark+24+i*19,nXBenchmark+73,nYBenchmark+42+i*19);
			CRect rcTurnScore(nXBenchmark+74,nYBenchmark+24+i*19,nXBenchmark+127,nYBenchmark+42+i*19);
			CRect rcCollectScore(nXBenchmark+128,nYBenchmark+24+i*19,nXBenchmark+197,nYBenchmark+42+i*19);

			//构造信息
			TCHAR szTurnScore[16]=TEXT(""),szCollectScore[16]=TEXT("");
			_sntprintf(szTurnScore,CountArray(szTurnScore),TEXT("%I64d"),m_pHistoryScore[i]->lTurnScore);
			_sntprintf(szCollectScore,CountArray(szCollectScore),TEXT("%I64d"),m_pHistoryScore[i]->lCollectScore);

			//绘画信息
			TCHAR strAccounts[64];
			_sntprintf(strAccounts,CountArray(strAccounts),TEXT("%s"),pUserData->szName);
			pDC->DrawText(strAccounts,lstrlen(strAccounts),&rcAccounts,nFormat);
			pDC->DrawText(szTurnScore,lstrlen(szTurnScore),&rcTurnScore,nFormat);
			pDC->DrawText(szCollectScore,lstrlen(szCollectScore),&rcCollectScore,nFormat);
		}
	}
	return;
}
示例#5
0
HRESULT ArchiverSession::CreateArchiveStore(const tstring& strUserName, const tstring& strServerName, LPMDB *lppArchiveStore)
{
	HRESULT hr = hrSuccess;
	MsgStorePtr ptrRemoteAdminStore;
	ECServiceAdminPtr ptrRemoteServiceAdmin;
	abentryid_t userId;
	ULONG cbStoreId = 0;
	EntryIdPtr ptrStoreId;
	ULONG cbRootId = 0;
	EntryIdPtr ptrRootId;
	MsgStorePtr ptrArchiveStore;
	MAPIFolderPtr ptrRoot;
	ULONG ulType;
	MAPIFolderPtr ptrIpmSubtree;
	SPropValuePtr ptrIpmSubtreeId;

	hr = GetUserInfo(strUserName, &userId, NULL, NULL);
	if (hr != hrSuccess)
		goto exit;

	hr = HrGetRemoteAdminStore(m_ptrSession, m_ptrAdminStore, strServerName.c_str(), fMapiUnicode, &ptrRemoteAdminStore);
	if (hr != hrSuccess)
		goto exit;

	hr = ptrRemoteAdminStore.QueryInterface(ptrRemoteServiceAdmin);
	if (hr != hrSuccess)
		goto exit;

	hr = ptrRemoteServiceAdmin->CreateEmptyStore(ECSTORE_TYPE_ARCHIVE, userId.size(), userId, EC_OVERRIDE_HOMESERVER, &cbStoreId, &ptrStoreId, &cbRootId, &ptrRootId);
	if (hr != hrSuccess)
		goto exit;

	// The entryids returned from CreateEmptyStore are unwrapped and unusable from external client code. So
	// we'll resolve the correct entryids through GetArchiveStoreEntryID.
	hr = ptrRemoteServiceAdmin->GetArchiveStoreEntryID(strUserName.c_str(), strServerName.c_str(), fMapiUnicode, &cbStoreId, &ptrStoreId);
	if (hr != hrSuccess)
		goto exit;

	hr = m_ptrSession->OpenMsgStore(0, cbStoreId, ptrStoreId, &ptrArchiveStore.iid, MDB_WRITE, &ptrArchiveStore);
	if (hr != hrSuccess)
		goto exit;

	hr = ptrArchiveStore->OpenEntry(0, NULL, &ptrRoot.iid, MAPI_MODIFY, &ulType, &ptrRoot);
	if (hr != hrSuccess)
		goto exit;

	hr = ptrRoot->CreateFolder(FOLDER_GENERIC, _T("IPM_SUBTREE"), _T(""), &IID_IMAPIFolder, fMapiUnicode, &ptrIpmSubtree);
	if (hr != hrSuccess)
		goto exit;

	hr = HrGetOneProp(ptrIpmSubtree, PR_ENTRYID, &ptrIpmSubtreeId);
	if (hr != hrSuccess)
		goto exit;

	ptrIpmSubtreeId->ulPropTag = PR_IPM_SUBTREE_ENTRYID;
	
	hr = ptrArchiveStore->SetProps(1, ptrIpmSubtreeId, NULL);
	if (hr != hrSuccess)
		goto exit;

	hr = ptrArchiveStore->QueryInterface(IID_IMsgStore, (LPVOID*)lppArchiveStore);

exit:
	return hr;
}
示例#6
0
//网络消息
bool CClientKernel::OnIPCSocket(const IPC_Head * pHead, const void * pIPCBuffer, WORD wDataSize, HWND hWndSend)
{
	ASSERT(pHead->wMainCmdID==IPC_MAIN_SOCKET);
	switch (pHead->wSubCmdID)
	{
	case IPC_SUB_SOCKET_RECV:	//数据接收
		{
			//效验数据
			ASSERT(wDataSize>=sizeof(CMD_Command));
			if (wDataSize<sizeof(CMD_Command)) return false;

			//提取数据
			WORD wPacketSize=wDataSize-sizeof(CMD_Command);
			IPC_SocketPackage * pSocketPackage=(IPC_SocketPackage *)pIPCBuffer;

			//特殊处理
			bool bHandle=false;
			ASSERT(m_pIClientKernelSink!=NULL);
			if (m_pIClientKernelSink==NULL) return true;
			if (wPacketSize==0)	bHandle=m_pIClientKernelSink->OnEventSocket(pSocketPackage->Command,NULL,0);
			else bHandle=m_pIClientKernelSink->OnEventSocket(pSocketPackage->Command,pSocketPackage->cbBuffer,wPacketSize);
			
			//框架消息
			if ((bHandle==false)&&(pSocketPackage->Command.wMainCmdID==MDM_GF_FRAME))
			{
				switch (pSocketPackage->Command.wSubCmdID)
				{
				case SUB_GF_OPTION:			//游戏配置
					{
						//效验参数
						ASSERT(wPacketSize==sizeof(CMD_GF_Option));
						if (wPacketSize!=sizeof(CMD_GF_Option)) return false;

						//消息处理
						CMD_GF_Option * pOption=(CMD_GF_Option *)pSocketPackage->cbBuffer;
						m_bGameStatus=pOption->bGameStatus;
						m_bAllowLookon=pOption->bAllowLookon?true:false;

						return true;
					}
				case SUB_GF_SCENE:			//游戏场景
					{
						return m_pIClientKernelSink->OnEventGameScene(m_bGameStatus,m_bLookonMode,pSocketPackage->cbBuffer,wPacketSize);
					}
				case SUB_GF_LOOKON_CONTROL:	//旁观控制
					{
						//效验参数
						ASSERT(wPacketSize==sizeof(CMD_GF_LookonControl));
						if (wPacketSize!=sizeof(CMD_GF_LookonControl)) return false;

						//消息处理
						if (IsLookonMode()==true)
						{
							//变量定义
							CMD_GF_LookonControl * pLookonControl=(CMD_GF_LookonControl *)pSocketPackage->cbBuffer;

							//事件处理
							m_bAllowLookon=(pLookonControl->bAllowLookon==TRUE)?true:false;

							//旁观处理
							m_pIClientKernelSink->OnEventLookonChanged(true,NULL,0);

							//提示消息
							if (m_bAllowLookon==true) m_pIMessageProxy->InsertSystemString(TEXT("您被允许观看玩家游戏"),0);
							else m_pIMessageProxy->InsertSystemString(TEXT("您被禁止观看玩家游戏"),0);
						}

						return true;
					}
				case SUB_GF_USER_CHAT:		//聊天信息
					{
						//效验参数
						CMD_GF_UserChat * pUserChat=(CMD_GF_UserChat *)pSocketPackage->cbBuffer;
						ASSERT(wPacketSize>=(sizeof(CMD_GF_UserChat)-sizeof(pUserChat->szChatMessage)));
						ASSERT(wPacketSize==(sizeof(CMD_GF_UserChat)-sizeof(pUserChat->szChatMessage)+pUserChat->wChatLength));
						if (wPacketSize<(sizeof(CMD_GF_UserChat)-sizeof(pUserChat->szChatMessage))) return false;
						if (wPacketSize!=(sizeof(CMD_GF_UserChat)-sizeof(pUserChat->szChatMessage)+pUserChat->wChatLength)) return false;

						//寻找用户
						tagUserData * pRecvUserData=NULL;
						tagUserData * pSendUserData=SearchUserItem(pUserChat->dwSendUserID);
						if (pSendUserData==NULL) return true;
						if (pUserChat->dwTargetUserID!=0L) pRecvUserData=SearchUserItem(pUserChat->dwTargetUserID);

						//消息过滤
						if ((pUserChat->dwSendUserID!=m_dwUserID)&&(pSendUserData->cbCompanion==enCompanion_Detest)) return true;

						//显示消息
						m_pIClientKernelSink->OnUserChatMessage(pSendUserData,pRecvUserData,pUserChat->szChatMessage,pUserChat->crFontColor);

						return true;
					}
				case SUB_GF_MESSAGE:		//系统消息
					{
						//效验参数
						CMD_GF_Message * pMessage=(CMD_GF_Message *)pSocketPackage->cbBuffer;
						ASSERT(wDataSize>(sizeof(CMD_GF_Message)-sizeof(pMessage->szContent)));
						if (wDataSize<=(sizeof(CMD_GF_Message)-sizeof(pMessage->szContent))) return false;

						//消息处理
						WORD wHeadSize=sizeof(CMD_GF_Message)-sizeof(pMessage->szContent);
						ASSERT(wPacketSize==(wHeadSize+pMessage->wMessageLength*sizeof(TCHAR)));
						if (wPacketSize!=(wHeadSize+pMessage->wMessageLength*sizeof(TCHAR))) return false;
						pMessage->szContent[pMessage->wMessageLength-1]=0;

						//中断判断
						if (pMessage->wMessageType&SMT_CLOSE_GAME) 
						{
							KillGameTimer(m_nTimerID);
							m_ChannelServiceHelper->CloseChannel(true,true);
						}

						//显示消息
						if (pMessage->wMessageType&SMT_INFO) m_pIMessageProxy->InsertSystemString(pMessage->szContent,MS_NORMAL);
						if (pMessage->wMessageType&SMT_EJECT) ShowMessageBox(pMessage->szContent,MB_ICONINFORMATION);

						//关闭房间
						if (pMessage->wMessageType&SMT_CLOSE_GAME)
						{
							m_bInquire=false;
							m_pIClientKernelSink->CloseGameFrame(true);
						}

						return true;
					}
				}
			}

			//礼物消息
			if ((bHandle==false)&&(pSocketPackage->Command.wMainCmdID==MDM_GF_PRESENT))
			{
				switch (pSocketPackage->Command.wSubCmdID)
				{
				case SUB_GF_FLOWER:			//赠送鲜花
					{
						//效验参数
						ASSERT(wPacketSize==sizeof(CMD_GF_GiftNotify));
						if (wPacketSize!=sizeof(CMD_GF_GiftNotify)) return false;

						//变量定义
						CMD_GF_GiftNotify * pGiftNotify=(CMD_GF_GiftNotify *)pSocketPackage->cbBuffer;
						if(pGiftNotify->cbSendLocation!=LOCATION_GAME_ROOM)return true;

						//获取玩家
						tagUserData const *pSendUserData = NULL;
						tagUserData const *pRcvUserData = NULL;
						for ( WORD wChairID = 0; wChairID < MAX_CHAIR; ++wChairID )
						{
							tagUserData const *pUserData = GetUserInfo( wChairID );
							if ( pUserData == NULL ) continue;

							if (pUserData->dwUserID == pGiftNotify->dwSendUserID )
							{
								pSendUserData = pUserData ;

								//自己判断
								if ( pGiftNotify->dwSendUserID == pGiftNotify->dwRcvUserID ) pRcvUserData = pSendUserData;
							}
							else if ( pUserData->dwUserID == pGiftNotify->dwRcvUserID ) pRcvUserData = pUserData;

							//中断判断
							if ( pSendUserData != NULL && pRcvUserData != NULL ) break;
						}

						//旁观搜索
						if ( pSendUserData == NULL || pRcvUserData == NULL )
						{
							for (INT_PTR i=0;i<m_UserItemLookon.GetCount();i++)
							{
								tagUserData *pLookonUserData = m_UserItemLookon[i];
								if ( pLookonUserData->dwUserID == pGiftNotify->dwSendUserID )
								{
									pSendUserData = pLookonUserData;

									//自己判断
									if ( pGiftNotify->dwSendUserID == pGiftNotify->dwRcvUserID ) pRcvUserData = pSendUserData;
								}
								else if ( pLookonUserData->dwUserID == pGiftNotify->dwRcvUserID ) pRcvUserData = pLookonUserData;

								//中断判断
								if ( pSendUserData != NULL && pRcvUserData != NULL ) break;
							}
						}

						//结果判断
						ASSERT( pSendUserData != NULL );
						ASSERT( pRcvUserData != NULL );
						if ( pSendUserData == NULL || pRcvUserData == NULL ) return true;
						ASSERT( pGiftNotify->wGiftID < FLOWER_COUNT ) ;
						if ( pGiftNotify->wGiftID >= FLOWER_COUNT ) return true;

						//构造消息
						CString strGiftMsg;
						int nFlowerID = pGiftNotify->wGiftID;

						//获取指针
						CSkinRichEdit *pSkinRichEdit = m_pIMessageProxy->GetRichEdit();

						pSkinRichEdit->InsertHyperLink(pSendUserData->szName, RGB(253,253,253));

						strGiftMsg = g_FlowerDescribe[nFlowerID].szAction;
						m_pIMessageProxy->InsertShtickString(strGiftMsg,RGB(255,0,255), strGiftMsg.GetLength(), false);

						pSkinRichEdit->InsertHyperLink(pRcvUserData->szName, RGB(253,253,253));

						strGiftMsg = g_FlowerDescribe[nFlowerID].szQuantifier1;
						m_pIMessageProxy->InsertShtickString(strGiftMsg,RGB(255,0,255), strGiftMsg.GetLength(), false);

						//插入图片
						CBitmap Bitmap;
						AfxSetResourceHandle(g_GlobalOption.m_PlatformResourceModule->GetResInstance());
						if ( Bitmap.LoadBitmap(g_GlobalOption.m_ChatExpViewImage.uChatGift[nFlowerID]) )
						{
							m_pIMessageProxy->InsertImage(&Bitmap);
							Bitmap.DeleteObject();
						}
						AfxSetResourceHandle(GetModuleHandle(NULL));

						WORD wFlowerCount = pGiftNotify->wFlowerCount;
						strGiftMsg.Format(TEXT(",共%d%s%s[ %s ]"), pGiftNotify->wFlowerCount, g_FlowerDescribe[nFlowerID].szQuantifier2,
							g_FlowerDescribe[nFlowerID].szResult, pRcvUserData->szName);
						m_pIMessageProxy->InsertShtickString(strGiftMsg,RGB(255,0,255), strGiftMsg.GetLength(), false);	

						strGiftMsg.Format(g_FlowerDescribe[nFlowerID].szCharmResult, wFlowerCount * abs(CPropertyBar::m_FlowerInfo[nFlowerID].lRcvUserCharm));
						m_pIMessageProxy->InsertShtickString(strGiftMsg,RGB(255,0,255), strGiftMsg.GetLength(), true);	

						//鲜花效果
						m_pIClientKernelSink->OnEventFlower(pSendUserData, pRcvUserData, nFlowerID, nFlowerID*2);

						return true;
					}
				case SUB_GF_RESIDUAL_PROPERTY:	//剩余道具
					{
						////效验参数
						//ASSERT(wPacketSize==sizeof(CMD_GF_ResidualProperty));
						//if (wPacketSize!=sizeof(CMD_GF_ResidualProperty)) return false;

						////变量定义
						//CMD_GF_ResidualProperty * ResidualProperty=(CMD_GF_ResidualProperty *)pSocketPackage->cbBuffer;

						////设置道具
						//for ( WORD wPropID = 0; wPropID < PROPERTY_COUNT; ++wPropID )
						//{
						//	m_pMeUserItem->dwPropResidualTime[wPropID] = ResidualProperty->dwResidualTime[wPropID];
						//}

						return true;
					}
				case SUB_GF_PROP_ATTRIBUTE:		//道具属性
					{
						//校验参数
						ASSERT( wPacketSize % sizeof(tagPropertyInfo) == 0 );
						if ( wPacketSize % sizeof(tagPropertyInfo) != 0 ) return true;

						//类型转换
						int nInfoCount = wPacketSize / sizeof(tagPropertyInfo);
						tagPropertyInfo *pPropertyInfo = (tagPropertyInfo*)pSocketPackage->cbBuffer;

						//设置属性
						m_pIClientKernelSink->OnEventInitProperty(pPropertyInfo, nInfoCount);

						return true;
					}
				case SUB_GF_FLOWER_ATTRIBUTE:	//鲜花属性
					{
						//校验参数
						ASSERT( wPacketSize % sizeof(tagFlowerInfo) == 0 );
						if ( wPacketSize % sizeof(tagFlowerInfo) != 0 ) return true;

						//类型转换
						int nInfoCount = wPacketSize / sizeof(tagFlowerInfo);
						tagFlowerInfo *pFlowerInfo= (tagFlowerInfo*)pSocketPackage->cbBuffer;

						//设置属性
						m_pIClientKernelSink->OnEventInitFlower(pFlowerInfo, nInfoCount);

						return true;
					}
				case SUB_GF_PROP_BUGLE:			//喇叭消息
					{
						ASSERT( sizeof(CMD_GF_BugleProperty) == wPacketSize );
						if ( sizeof(CMD_GF_BugleProperty) != wPacketSize ) return false;

						//类型转换
						CMD_GF_BugleProperty *pBugleProperty = (CMD_GF_BugleProperty*)pSocketPackage->cbBuffer;

						//喇叭图片
						CBitmap Bitmap;
						AfxSetResourceHandle(g_GlobalOption.m_PlatformResourceModule->GetResInstance());
						if ( Bitmap.LoadBitmap(g_GlobalOption.m_ChatExpViewImage.uChatBugle) )
						{
							m_pIMessageProxy->InsertImage(&Bitmap);
							Bitmap.DeleteObject();
						}
						AfxSetResourceHandle(GetModuleHandle(NULL));

						//喇叭内容
						m_pIMessageProxy->InsertUserChat(pBugleProperty->szUserName,pBugleProperty->szContext,pBugleProperty->crText,MS_NORMAL);

						return true;
					}
				}
			}

			return bHandle;
		}
	}

	return false;
}
示例#7
0
int dSocketCheck( )
{
	int     dSfd;
	int		dRecvLen = 0;
	int		dSelRet;
	int		dRet, dRet1, i, j;
	int		dAdminIdx;
	int		dSocketChkFlag = 0;
	char	szTcpRmsg[MAX_MNG_PKT_BUFSIZE];

	fd_set  stRd;
	fd_set	stWd;
	struct  timeval		timeout;

	memcpy((char*)&stRd, (char*)&gstReadfds, sizeof(fd_set));
	memcpy((char*)&stWd, (char*)&gstWritefds, sizeof(fd_set));

	timeout.tv_sec = 0;
	timeout.tv_usec = 10000;

	dSelRet = select( gdNumfds+1, &stRd, &stWd, (fd_set*)NULL, &timeout );
	if( dSelRet < 0 ) {
		if( errno != EINTR ) {
			/*
			* SELECT UNEXPECTED ERROR
			*/
			log_print(LOGN_CRI, "[ERROR] SELECT CRITICAL ERROR INVOKE [%d] [%s]",
							 errno, strerror(errno) );
			FinishProgram();
		}
		return 0;
	}
	else if( dSelRet > 0 ) {					/*** EVENT INVOKE ***/

		if( FD_ISSET( gdSvrSfd, &stRd ) ) {		/*** NEW CLIENT CONNECT ***/

			log_print(LOGN_DEBUG, "[SOCKET] NEW CLIENT CONNECT TRIAL SVRPORT[%d]",
							   gdPortNo );
			dSocketChkFlag++;

			dRet = dAcceptClient();
			if( dRet < 0 ) {
				log_print( LOGN_CRI, "FAIL IN FUNCTION dAcceptClient()");
			}
		}

		for( i=0; i<gdClient; i++ )	{
			if( stConTbl[i].dSfd < 0 )
				continue;

			log_print(LOGN_DEBUG, "[SOCKET] stConTbl IDX[%d] SFD[%d] dSetRet[%d] IP[%s]",
							   i, stConTbl[i].dSfd, dSelRet, util_cvtipaddr(NULL, stConTbl[i].uiCliIP) );

			dSfd = stConTbl[i].dSfd;
			if(FD_ISSET( dSfd, &stRd)) {		/*** EXIST CLIENT EVENT ***/
				log_print(LOGN_DEBUG, "[SOCKET] EXIST CLIENT EVENT IDX[%d] Sfd[%d] IP[%s]",
					i, dSfd, util_cvtipaddr(NULL, stConTbl[i].uiCliIP) );
				dSocketChkFlag++;

				dRecvLen = 0;

				dRet = dRecvMessage(dSfd, &szTcpRmsg[0], &dRecvLen );
				if( dRet < 0 ) {
					log_print(LOGN_CRI, "[SOCKET] [CLOSE  ] CONNECTION CLOSE IDX[%d] SFD[%d] IP[%s]",
									  	i, dSfd, util_cvtipaddr(NULL, stConTbl[i].uiCliIP) );

					close(dSfd);
					FD_CLR( dSfd, &gstReadfds );

					log_print(LOGN_DEBUG, "GDCLIENT INFO : [%d]", gdClient );

					if( gdClient == 1 ) {
                        gdClient--;
						gdNumfds = gdSvrSfd;
					}
                    else if( (gdClient-1) == i ) {
                        gdClient--;

                        while(1) {
                            if( stConTbl[gdClient-1].dSfd > 0 ) {
								gdNumfds = dGetMaxFds();
                                break;
							}
                            else {
                                gdClient--;

                                if( gdClient == 0 ) {
									log_print(LOGN_DEBUG, "GDNumfds INFO 4 : [%d]", gdNumfds );
									gdNumfds = gdSvrSfd;
                                    break;
								}
                            }
                        }
                    }

					/*
					* ADD 2003.05.13.
					* CLEAR WRITE FD_SET FOR SOCKET FD
					*/
            		memcpy((char*)&stWd, (char*)&gstWritefds, sizeof(fd_set));
            		if( FD_ISSET( dSfd, &stWd ) ) {
                		log_print(LOGN_DEBUG, "CLEAR WRITEFDS FOR SOCKET CLOSE SFD[%d]", dSfd );

                		FD_CLR( dSfd, &gstWritefds );

                		gdNumWfds--;
                		stConTbl[i].cSockBlock = 0x00;
            		}

					log_print(LOGN_DEBUG, "GDCLIENT INFO : [%d]", gdClient );

					stConTbl[i].dSfd = -1;
					stConTbl[i].dBufLen = 0;
					stConTbl[i].uiCliIP = 0;
					stConTbl[i].cRetryCnt = 0;

					dAdminIdx = GetUserInfo( stConTbl[i].adminid, 1 );
					stAdmin.dConnectFlag[dAdminIdx] = 0;

					stConTbl[i].adminid[0] = 0x00;

					for( j=0 ; j < MAX_TMR_REC ; j++ ) {
						if( dSfd == run_tbl->sfd[j] ) {
							clear_my_tmr( j );
						}
					}
				}
				else if(dRecvLen > 0) {
					log_print( LOGN_DEBUG, "RECV SOCK SIZE[%d]", dRecvLen );

					dRet = dMergeBuffer( i, dSfd, szTcpRmsg, dRecvLen );
					if( dRet < 0 ) {
						log_print(LOGN_CRI,
							"[SOCKET] [CLOSE  ] PACKET MERGE ERR->CONNECTION CLOSE IDX[%d] sfd[%d] Ret[%d] IP[%s]",
							i, dSfd, dRet, util_cvtipaddr(NULL, stConTbl[i].uiCliIP) );

						close(dSfd);
						FD_CLR( dSfd, &gstReadfds );

						log_print(LOGN_DEBUG, "GDCLIENT INFO : [%d]", gdClient );

						if( gdClient == 1 ) {
                            gdClient--;
							log_print(LOGN_DEBUG, "GDNumfds INFO : [%d]", gdNumfds );
							gdNumfds = gdSvrSfd;
						}
                        else if( (gdClient-1) == i ) {
                            gdClient--;

                            while(1) {
                                if( stConTbl[gdClient-1].dSfd > 0 ) {
									gdNumfds = dGetMaxFds();
                                    break;
								}
                                else {
                                    gdClient--;

                                    if( gdClient == 0 ) {
										log_print(LOGN_DEBUG, "GDNumfds INFO 2 : [%d]", gdNumfds );
										gdNumfds = gdSvrSfd;
                                        break;
									}
                                }
                            }
                        }

						/*
						* ADD 2003.05.13.
						*/
            			memcpy((char*)&stWd, (char*)&gstWritefds, sizeof(fd_set));
            			if( FD_ISSET( dSfd, &stWd ) ) {
                			log_print(LOGN_DEBUG,"CLEAR WRITEFDS FOR SOCKET CLOSE SFD[%d]", dSfd );

                			FD_CLR( dSfd, &gstWritefds );

                			gdNumWfds--;
                			stConTbl[i].cSockBlock = 0x00;
            			}

						log_print(LOGN_DEBUG, "GDCLIENT INFO : [%d]", gdClient );

						stConTbl[i].dSfd = -1;
						stConTbl[i].dBufLen = 0;
						stConTbl[i].uiCliIP = 0;
						stConTbl[i].cRetryCnt = 0;

						dAdminIdx = GetUserInfo( stConTbl[i].adminid, 1 );
						stAdmin.dConnectFlag[dAdminIdx] = 0;

						stConTbl[i].adminid[0] = 0x00;
						for( j=0 ; j < MAX_TMR_REC ; j++ ) {
							if( dSfd == run_tbl->sfd[j] ) {
								clear_my_tmr( j );
							}
						}
					}
				}
			}
		}

		/*
		* CHECK WRITE FD_SET
		*/
		if( gdNumWfds > 0 ) {
			for( i=0; i<gdClient; i++ ) {
				if( stConTbl[i].dSfd < 0  )
					continue;

				if( stConTbl[i].cSockBlock == 0x00 )
					continue;

				dSocketChkFlag++;
				dSfd = stConTbl[i].dSfd ;

				if( FD_ISSET( dSfd, &stWd ) ) {
					log_print(LOGN_DEBUG,"WriteFds Event Invoke SFD[%d]", dSfd );

					FD_CLR( dSfd, &gstWritefds );

					gdNumWfds--;
					stConTbl[i].cSockBlock = 0x00;

					/*
					* SEND SENDBUFFER DATA
					*/
					if( stConTbl[i].dBufLen > 0 ) {
						dRet = dSendBlockMessage( dSfd, stConTbl[i].dBufLen, &stConTbl[i].szSendBuffer[0], i );
						dRet1 = dSetSockBlock( dRet, dSfd, i );
					}
				}
			}
		}

		if( dSocketChkFlag == 0 && dSelRet > 0 ) {
			log_print( LOGN_INFO,
				"CHECK SOCKET SELECT dSelRet[%d] gdNumWfds[%d]",
				dSelRet, gdNumWfds);
			sleep(1);
		}
	}
	else if( dSelRet == 0 ) {
		/*
		* NO EVENT
		*/
	}

	return 0;
}
示例#8
0
int main (int argc, char *argv[]) {
	int c;
	unsigned long hostaddr;
	FILE *cmdfile;
	char *cmdline = NULL;
	char *cmdtok = NULL;
	char *filename = NULL;
	char line[MAXLEN];
	char tmpcmd[MAXLEN];
	debug=0;verbose=0;errpause=0;skiperr=0;allocpty=0;envfl=0;
	timeout=5;
	enable_trace=0;
	tracelvl=0;
	errfile=NULL;
	envfilenm=NULL;
	appname = basename(argv[0]);
	while ((c = getopt (argc, argv, "dhpvP :c:f:t:s:e:T:")) != -1) {
		switch (c) {
			case 'c':
				cmdline = optarg;
				break;
				
			case 'd':
				debug++;
				break;
				
			case 'f':
				filename = optarg;
				break;
				
			case 'h':
				PrintUsage();
				break;
				
			case 'p':
				errpause++;
				break;
				
			case 'P':
				allocpty++;
				break;
				
			case 'e':
				envfl++;
				envfilenm = optarg;
				break;
				
			case 's':
				skiperr++;
				errfile = optarg;
				break;
				
			case 't':
				timeout = (int) strtol(optarg, (char **)NULL, 10);
				break;
				
			case 'T':
				enable_trace++;
				tracelvl = (int) strtol(optarg, (char **)NULL, 10);
				break;
				
			case 'v':
				verbose++;
				break;
				
			case '?':
				PrintUsage();
				break;
		}
	}
	
	ValidateOptions(cmdline,filename);
	
	if ((argc - optind) == 1) {
		hostaddr = GetHostInfo((char *)argv[optind]);
	} else {
        fprintf(stderr, "Hostname or IP is required\n\n");
        PrintUsage();
	}
	
	/* Get Username from effecive user id running the program */
	GetUserInfo();
	
	/* Initialize the Session */
	InitSession(hostaddr);
	
	if (cmdline != NULL) {
		RunCommand(cmdline);
	} else {
		if ((cmdfile = fopen(filename, "r")) == 0) {
			fprintf(stderr, "Could not open file %s:%s\n",
					filename ,strerror(errno));
			exit(-1);
		}
		
		strcpy(tmpcmd,"");
		while (fgets(line, sizeof(line), cmdfile) != NULL) {
			cmdtok = strdup(line);
			if (CheckLine(trim(cmdtok))) {
				sprintf(tmpcmd,"%s%s",tmpcmd,cmdtok);
			} else {
				if ( strcmp(tmpcmd,"") != 0 ) {
					sprintf(tmpcmd,"%s%s",tmpcmd,cmdtok);
					free(cmdtok);
					cmdtok = strdup(tmpcmd);
				}
				if (strlen(cmdtok) > 1 && SkipComments(cmdtok) ) {
					RunCommand(cmdtok);
				}
				strcpy(tmpcmd,"");
			}
			free(cmdtok);
		}
		if (strcmp(tmpcmd,"") != 0) {
			RunCommand(tmpcmd);
			strcpy(tmpcmd,"");
		}
	}
	CleanupSession(session,username);
	return 0;
}
示例#9
0
/**
 *	Implement func.
 */
int main(int argc, char *argv[])
{
	int			dRet, i, loopCnt;
	int			dNmsIndex;
	//st_MsgQ  	stMsg;
	pst_MsgQ	pstMsg;				/* msgq ==> gifo */
	pst_MsgQSub pstMsgQSub;
	int			dWarnOutCnt = 0;	/* 20040923,poopee */
	char		szCommand[64];
    time_t		tCurTime, tCheckTime, tClientCheck, tLastPingMySQL;
	OFFSET		offset;

	SetUpSignal();

	gdStopFlag = 1;
	gdNumfds = 0;
	gdNumWfds = 0;

	log_init(S_SSHM_LOG_LEVEL, getpid(), SEQ_PROC_MMCD, LOG_PATH"/MMCD", "MMCD");

	/*
	AppLogInit(getpid(), SEQ_PROC_MMCD, MMCD_LOG, "MMCD");
	dRet = dInitLogShm();
	if( dRet < 0 )
		exit(dRet);

	dRet = Init_shm_common();
    if(dRet < 0)
    {
        log_print( LOGN_CRI,"MAIN : Failed in Init_shm_common dRet[%d][%s]", dRet, strerror(errno));
        exit(1);

	*/

	if((dRet = get_db_conf(FILE_MYSQL_CONF, szIP, szName, szPass, szAlias)) < 0)
	{
		log_print(LOGN_CRI, "F=%s:%s.%d: ERROR IN get_db_conf() dRet[%d]", __FILE__, __FUNCTION__, __LINE__, dRet);
		exit(-5);
	}

	if((dRet = db_conn(&stMySQL, szIP, szName, szPass, szAlias)) < 0)
	{
			log_print(LOGN_CRI, "F=%s:%s.%d: ERROR IN db_conn() dRet[%d]", __FILE__, __FUNCTION__, __LINE__, dRet);
		exit(-6);
	}

	/*
	if( (dRet = dInitialMysqlEnvironment(&stConnInfo)) < 0)
	{
		log_print(LOGN_CRI, "F=%s:%s.%d: ERROR IN dInitialMysqlEnvironment() dRet[%d]",
			__FILE__, __FUNCTION__, __LINE__, dRet);
		exit(-2);
	}

	if( (dRet = dConnectMySQL(&stMySQL, &stConnInfo)) < 0)
	{
		log_print(LOGN_CRI, "F=%s:%s.%d: ERROR IN dConnectMySQL() dRet[%d]",
			__FILE__, __FUNCTION__, __LINE__, dRet);
		exit(-3);
	}
	*/

	/*
	* INITIALIZE FOR MMC COMMAND
	*/
	dRet = init_mmc_server();
	if( dRet < 0 ) {
		log_print(LOGN_CRI, "[ERROR] INIT_MMC_SERVER RET[%d]\n", dRet );
		FinishProgram();
		exit(0);
	}
	/*
	* INITIALIZE FOR SHARED MEMORY FIDB
	*/
/*
	dRet = Init_Fidb();
    if( dRet < 0 ) {
        log_print(LOGN_CRI,"[ERROR] FIDB INIT [%d]\n", dRet );
        FinishProgram();
        exit(0);
    }
*/

	/*
	* INITIALIZE SOCKET
	*/
	dRet = dTcpSvrModeInit();
	if( dRet < 0 ) {
		FinishProgram();
		exit(0);
	}

	/*
	* INITIALIZE FOR SOCKET CONNECTION TABLE
	*/
	for( i = 0 ; i < MAX_FDSET2	; i++ ) {
		stConTbl[i].dSfd = -1;
		stConTbl[i].uiCliIP = 0;
		stConTbl[i].dBufLen = 0;
        stConTbl[i].szSendBuffer[0] = 0;
        stConTbl[i].cSockBlock = 0x00;
		gstMsgBuf[i].dWidx = 0;
		gstMsgBuf[i].dRidx = 0;
		memset( gstMsgBuf[i].szBuf, 0x00, sizeof(MAX_MNG_PKT_BUFSIZE) );
	}

	/*
	* GET MESSAGE QUEUE ID USING IN MMCD
	*/
    dRet = dInitIPCs();
	if( dRet < 0 ) {
		log_print(LOGN_CRI,"[ERROR] MyQid GET RET[%d]", dRet );
		FinishProgram();
		exit(0);
	}

	/* moved from init_mmc_server() */
	/* CLEAN UP ALL WARN-OUT DATA */
	for(;;) 
	{

/* msgq ==> gifo */
#if 0
		dRet = msgrcv(gdMyQid, &stMsg, sizeof(st_MsgQ) - sizeof(long int), 0, IPC_NOWAIT | MSG_NOERROR);
		if( dRet <= 0) break;
		else dWarnOutCnt++;
#endif
		offset = gifo_read(gpRECVMEMS, pCIFO, SEQ_PROC_MMCD);
		if(offset <= 0)
		{
			usleep(0);
			break;
		}
		else
		{
			dWarnOutCnt++;
			//pstMsg = (pst_MsgQ)nifo_get_value(gpRECVMEMS, DEF_MSGQ_NUM, offset);
			nifo_node_delete(gpRECVMEMS, nifo_ptr(gpRECVMEMS, offset));
		}	
	}
	log_print(LOGN_INFO, "INITIAL MESSAGE QUEUE WARN-OUT COUNT : [%d]", dWarnOutCnt );

	gdIndex = 0;
	dNmsIndex = GetUserInfo("ntasnms", 1 );

	time(&tCurTime);
	tClientCheck = tCheckTime = tCurTime;

	if( (dRet = set_version(S_SSHM_VERSION, SEQ_PROC_MMCD, vERSION)) < 0)
	{
		log_print(LOGN_WARN, "set_version error(ret=%d,idx=%d,ver=%s)\n", dRet, SEQ_PROC_MMCD, vERSION);
	}
	log_print(LOGN_CRI, "MMCD %s Started", vERSION);

	/*
	* MAIN WHILE LOOP
	*/
	while(gdStopFlag)
	{

		loopCnt = 0;
		while(1)
		{
			/* msgq ==> gifo */
			if( (dRet = dIsRcvedMessage(&pstMsg)) > 0)
			{
				pstMsgQSub	= (pst_MsgQSub)&pstMsg->llMType;
				log_print(LOGN_INFO, "RECEIVED MSGQ: Type[%d] SvcID[%d] MsgID[%d] usBodyLen[%d]", pstMsgQSub->usType, pstMsgQSub->usSvcID, pstMsgQSub->usMsgID, pstMsg->usBodyLen);
				if( (pstMsgQSub->usSvcID == SID_PATCH) && (pstMsgQSub->usMsgID == MID_SMNG_START))
				{
					sprintf(szCommand, "/WNTAMAPP/BIN/StartMC -b S_MNG");
					system(szCommand);
					log_print(LOGN_INFO, "S_MNG START MESSAGE GET");
					continue;
				}
				SendToOMP( (dbm_msg_t*)&pstMsg->szBody[0], pstMsg->usBodyLen);
				
				// TODO 제대로 된 코드인지 확인 필요
				nifo_node_delete(gpRECVMEMS, nifo_ptr(gpRECVMEMS, nifo_get_offset_node(gpRECVMEMS, (U8*)pstMsg)));
			}
			else
			{
				usleep(0);
				loopCnt++;
				if( loopCnt > 100 ){
					break;
				}
			}

#if 0
			memset(&stMsg, 0x00, sizeof(st_MsgQ));
			if( (dRet = dIsRcvedMessage(&stMsg)) > 0)
			{
				pstMsgQSub	= (pst_MsgQSub)&stMsg.llMType;
				log_print(LOGN_INFO, "RECEIVED MSGQ: Type[%d] SvcID[%d] MsgID[%d] usBodyLen[%d]", pstMsgQSub->usType, pstMsgQSub->usSvcID, pstMsgQSub->usMsgID, stMsg.usBodyLen);
				if( (pstMsgQSub->usSvcID == SID_PATCH) && (pstMsgQSub->usMsgID == MID_SMNG_START))
				{
					sprintf(szCommand, "/WNTAMAPP/BIN/StartMC -b S_MNG");
					system(szCommand);
					log_print(LOGN_INFO, "S_MNG START MESSAGE GET");
					continue;
				}
				SendToOMP( (dbm_msg_t*)&stMsg.szBody[0], stMsg.usBodyLen);

				
				
				nifo_node_delete(gpRECVMEMS, nifo_ptr(gpRECVMEMS, offset));
			}
			else if(dRet < 0)
			{
				log_print(LOGN_CRI, "[ERROR] dIsRcvedMessage PROGRAM FINISHED");
				exit(0);
			}
			else
				break;
#endif

		}

		/*
		* MAIN SOCKET CHECK
		*/
		dRet = dSocketCheck();

		/*
		* CHECK COMMAND TIMEOUT
		*/
		time(&tCurTime);

		if(abs(tCurTime-tCheckTime) >= 1)
		{
			Timer(tCurTime);
			tCheckTime = tCurTime;
		}

		/*
		* CHECK CLIENT FOR UNUSUAL CLOSE : CLIENT_CHECK_TIME(10)
		*/
		if(abs(tCurTime-tClientCheck) > CLIENT_CHECK_TIME)
		{
			CheckClient(0);
			tClientCheck = tCurTime;
		}

		if( (tCurTime - tLastPingMySQL) > SEC_OF_HOUR)
		{
			//if( (dRet = dPingMySQL(&stMySQL)) < 0)
			if((dRet = db_check_alive(&stMySQL)) < 0)
			{
				log_print(LOGN_CRI,"F=%s:%s.%d: ERROR IN dPingMySQL() dRet[%d]", __FILE__, __FUNCTION__, __LINE__, dRet);
				return -16;
			}
			tLastPingMySQL = tCurTime;
		}
	}
	FinishProgram();
	log_print(LOGN_CRI, "[EXIT] PROGRAM END !!!\n");

	return 0;
}
示例#10
0
int dInsert_MMCD_Result(st_MngPkt *pstMngPkt, short tmrID, char *szBuf, int dSockfd)
{
	int					dRet;
	size_t				szLen;
	st_SysMMCDMsg		stData;
	struct sockaddr_in	sa;
	socklen_t			sock_len;

	memcpy(stData.szUserName, pstMngPkt->head.userName, MAX_USER_NAME-1);
	stData.szUserName[MAX_USER_NAME-1] = 0x00;
	stData.uiTime = time(NULL);
	g_usSeq++;

	stData.usSeq = g_usSeq;

	if(g_usSeq >= 999)
		g_usSeq = 0;

	strcpy( (char*)stData.szCommand, g_cmd_line);
	szLen = strlen(szBuf);
	if(szLen >= MAX_MMCD_MSG_SIZE)
	{
		log_print(LOGN_WARN, "MMCD RESULT DB INSERT BUFFER OVERFLOW MAX:%d CUR=%ld", MAX_MMCD_MSG_SIZE, szLen);
		szLen = MAX_MMCD_MSG_SIZE - 1;
	}

	memcpy(stData.szMessage, szBuf, szLen);
	stData.szMessage[szLen] = 0x00;

	if(pstMngPkt->head.usResult > 0)
		stData.usResult = 1;
	else
		stData.usResult = 0;

	if(dSockfd != 0)
	{
	    /* get a informations of this clients.	*/
	    sock_len = (socklen_t)sizeof(sa);
	    if(getpeername(dSockfd, (struct sockaddr*)&sa, &sock_len) == -1)
	    {
			if(strcasestr(stData.szCommand, "USER-LOGOUT") == NULL)
			{
				log_print(LOGN_CRI, "F=%s:%s.%d: FAILED IN getpeername(run_tbl->sfd[%hd][%d]) errno[%d-%s]", __FILE__, __FUNCTION__, __LINE__,
					tmrID, dSockfd, errno, strerror(errno));
				return -1;
			}
			else
				stData.uiUserBIP = stAdmin.stUserList[GetUserInfo(stData.szUserName,1)].lLastLoginIP;
	    }
	    stData.uiUserBIP	= htonl(sa.sin_addr.s_addr);
	}
	else
		stData.uiUserBIP	= 0;

	if( (dRet = dInsert_MMCDMsg(&stMySQL, &stData)) < 0)
	{
		if(dRet == -1)
		{
			if( (dRet = dCreate_MMCDMsg(&stMySQL)) < 0)
			{
				log_print(LOGN_CRI, "F=%s:%s.%d: FAILED IN dCreate_MMCDMsg() dRet[%d]", __FILE__, __FUNCTION__, __LINE__, dRet);
				return -2;
			}

			if( (dRet = dInsert_MMCDMsg(&stMySQL, &stData)) < 0)
			{
				log_print(LOGN_CRI, "F=%s:%s.%d: FAILED IN dInsert_MMCDMsg() dRet[%d]", __FILE__, __FUNCTION__, __LINE__, dRet);
				return -3;
			}
		}
		else if(dRet == -2)
		{
			log_print(LOGN_CRI, "F=%s:%s.%d: FAILED IN dInsert_MMCDMsg() dRet[%d-DB_STOP]", __FILE__, __FUNCTION__, __LINE__, dRet);
			exit(1);
		}
		else
			log_print(LOGN_DEBUG, "F=%s:%s.%d: FAILED IN dInsert_MMCDMsg() dRet[%d]", __FILE__, __FUNCTION__, __LINE__, dRet);
	}

	return 0;
}
示例#11
0
int out_print(char *outbuf, dbm_msg_t *msg, unsigned short usLen, short tmrID, short sRet, short cont_flag)
{
	short		CurCount, TotCount;
	int			dRet, dRet1, dNmsSfd, dNmsUserIdx, dConTblIdx, dLen;
	char		szTempBuf[MAX_MMCD_MSG_SIZE*2];
	st_MngPkt	output;

	memset(&output, 0x00, sizeof(st_MngPkt));

	if(run_tbl->ucbinflag[tmrID] == 0x00)
	{
		if(cont_flag == DBM_CONTINUE)
			sprintf(szTempBuf, "\n%s %s\n%s\nCONTINUED\n", SmsName, (char*)ComposeHead(), outbuf);
		else
			sprintf(szTempBuf, "\n%s %s\n%s\nCOMPLETED\n", SmsName, (char*)ComposeHead(), outbuf);
		output.head.usBodyLen = strlen(szTempBuf);
	}
	else
	{
		if(sRet < 0)
		{
			if(cont_flag == DBM_CONTINUE)
				sprintf(szTempBuf, "\n%s %s\n%s\nCONTINUED\n", SmsName, (char*)ComposeHead(), outbuf);
			else
				sprintf(szTempBuf, "\n%s %s\n%s\nCOMPLETED\n", SmsName, (char*)ComposeHead(), outbuf);
			output.head.usBodyLen = strlen(szTempBuf);
		}
		else
		{
			memcpy(szTempBuf, &outbuf[0], usLen);
			output.head.usBodyLen = usLen;
		}
	}

	if(output.head.usBodyLen >= MAX_MNGPKT_BODY_SIZE)
	{
		log_print(LOGN_WARN, "MMCD OUTPUT PRINT BODY MESSAGE OVER FLOW MAX=%d CUR=%d", MAX_MMCD_MSG_SIZE, output.head.usBodyLen);
		output.head.usBodyLen = MAX_MNGPKT_BODY_SIZE - 1;
	}

	memcpy(output.data, szTempBuf, output.head.usBodyLen);
	output.data[output.head.usBodyLen] = 0x00;
	if( (run_tbl->ucbinflag[tmrID]==1) && (sRet >= 0))
		log_print(LOGN_DEBUG, "BinResult=%d BODYLEN=%d BINARY FORMAT", run_tbl->ucbinflag[tmrID], output.head.usBodyLen);
	else
		log_print(LOGN_DEBUG, "BinResult=%d BODYLEN=%d BODY=[%s]", run_tbl->ucbinflag[tmrID], output.head.usBodyLen, output.data);

	output.head.ucBinFlag		= run_tbl->ucbinflag[tmrID];
	output.head.llMagicNumber	= MAGIC_NUMBER;
	output.head.llIndex			= run_tbl->llIndex[tmrID];

	/*** STATISTIC INFORMATION FOR NMS ****************************************/
	output.head.usTotPage	= msg->common.TotPage;
	output.head.usCurPage	= msg->common.CurPage;
	output.head.usStatFlag	= msg->common.StatFlag;

	if(sRet == DBM_SUCCESS)
		output.head.usResult = cont_flag;
	else
		output.head.usResult = sRet;

	output.head.usTotLen = output.head.usBodyLen+MNG_PKT_HEAD_SIZE;

	output.head.usSrcProc = run_tbl->inv_proc[tmrID];
	memcpy(output.head.TimeStamp, run_tbl->time_stamp[tmrID], sizeof(run_tbl->time_stamp[tmrID]));
	memcpy(output.head.userName, run_tbl->user_name[tmrID], 24);

	output.head.ucSvcID = SID_MML;
	output.head.ucMsgID = MID_MML_RST;
	memcpy(&output.head.ucmmlid[0], &run_tbl->usmmlid[tmrID], sizeof(unsigned short));

	log_print(LOGN_DEBUG, "**********TOTAL=%d BODY=%d", output.head.usTotLen, output.head.usBodyLen);

	dConTblIdx = dGetConTblIdx(run_tbl->sfd[tmrID]);

	dRet	= dSendMessage(run_tbl->sfd[tmrID], output.head.usTotLen, (char*)&output, dConTblIdx);
	dRet1	= dSetSockBlock(dRet, run_tbl->sfd[tmrID], dConTblIdx);

	// If This CMD for Binary Format, This Message will be maden for String MSG
	if( (run_tbl->ucbinflag[tmrID]==1) && (sRet>=0))
	{
		strcpy(szTempBuf, (char*)ComposeHead());
		dLen = strlen(szTempBuf);
		if(lib_tbl[msg->head.msg_id%MAX_LIB_TABLE].mmc_res != NULL)
		{
			sprintf(szTempBuf+dLen, "M%04d  %s", lib_tbl[msg->head.msg_id%MAX_LIB_TABLE].mcode, lib_tbl[msg->head.msg_id%MAX_LIB_TABLE].msg_header);

			CurCount = run_tbl->stat_cur_cnt[tmrID];
			TotCount = run_tbl->stat_tot_cnt[tmrID];

			(*lib_tbl[msg->head.msg_id%MAX_LIB_TABLE].mmc_res)(szTempBuf+dLen, msg, &CurCount, &TotCount);
		}

		if(cont_flag == DBM_CONTINUE)
			strcat(szTempBuf, "\nCONTINUED\n");
		else
			strcat(szTempBuf, "\nCOMPLETED\n");

		output.head.usBodyLen = strlen(szTempBuf);
		if(output.head.usBodyLen >= MAX_MMCD_MSG_SIZE)
		{
			log_print(LOGN_WARN, "MMCD OUTPUT PRINT BIN to TEXT BODY MESSAGE OVER FLOW MAX=%d CUR=%d", MAX_MMCD_MSG_SIZE, output.head.usBodyLen);
			output.head.usBodyLen = MAX_MMCD_MSG_SIZE - 1;
		}
		memcpy(output.data, szTempBuf, output.head.usBodyLen);
		output.data[output.head.usBodyLen] = 0x00;
		output.head.usTotLen = output.head.usBodyLen+MNG_PKT_HEAD_SIZE;
		log_print(LOGN_INFO, "BINARY FORMAT to STRING FORMAT BODYLEN=[%d][%s]", output.head.usBodyLen, output.data);
	}

	dNmsSfd = dGetNMSsfd();
	dNmsUserIdx = GetUserInfo("nmsnms", 1);
	log_print(LOGN_DEBUG, "NMS SFD:[%d] CURRENT SFD:[%d]", dNmsSfd, run_tbl->sfd[tmrID]);
	if( (dNmsSfd>0) && (dNmsSfd!=run_tbl->sfd[tmrID]) && (stAdmin.dConnectFlag[dNmsUserIdx]==1))
	{
		log_print(LOGN_INFO, "[INFO] SEND RESULT MESSAGE TO NMS Len=%d[%s]", output.head.usBodyLen, output.data);

		dConTblIdx	= dGetConTblIdx(dNmsSfd);
		dRet		= dSendMessage(dNmsSfd, output.head.usTotLen, (char*)&output, dConTblIdx);
		dRet1		= dSetSockBlock(dRet, dNmsSfd, dConTblIdx);
	}
	dRet = dInsert_MMCD_Result(&output, tmrID, outbuf, run_tbl->sfd[tmrID]);

	return 0;
}
示例#12
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageBack,enMode_Spread);

	//装饰位图
	CImageHandle DecorateHandle(&m_ImageDecorate);
	m_ImageDecorate.BitBlt(pDC->m_hDC,m_nXBorder+10,m_nYBorder+5);

	//用户区域
	CImageHandle UserInfoHandle(&m_ImageUserInfo);
	int nXPos=m_nXBorder+5;
	int nYPos=(nHeight-m_UserInfoSize.cy)/2-30;
	m_ImageUserInfo.BitBlt(pDC->m_hDC,nXPos,nYPos);

	//棋子标志
	if (m_wBlackUser!=INVALID_CHAIR)
	{
		CImageHandle FlagHandle(&m_ImageFlag);
		m_ImageFlag.BitBlt(pDC->m_hDC,m_ChessFlagPoint[0].x,m_ChessFlagPoint[0].y,m_ImageFlag.GetWidth()/2,m_ImageFlag.GetHeight(),
			(m_wBlackUser==0)?0:m_ImageFlag.GetWidth()/2,0);
		m_ImageFlag.BitBlt(pDC->m_hDC,m_ChessFlagPoint[1].x,m_ChessFlagPoint[1].y,m_ImageFlag.GetWidth()/2,m_ImageFlag.GetHeight(),
			(m_wBlackUser==1)?0:m_ImageFlag.GetWidth()/2,0);
	}

	//绘画用户
	WORD wUserTimer=0;
	pDC->SetTextColor(RGB(255,255,255));
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		CRect rcName;
		const tagUserData * pUserData=GetUserInfo(i);
		if (pUserData!=NULL)
		{
			//用户区域
			rcName.top=m_ptName[i].y;
			rcName.left=m_ptName[i].x;
			rcName.right=m_ptName[i].x+102;
			rcName.bottom=m_ptName[i].y+12;
			pDC->DrawText(pUserData->szName,lstrlen(pUserData->szName),&rcName,DT_SINGLELINE|DT_END_ELLIPSIS);

			//用户时间
			DrawUserClock(pDC,m_ptTimer[i].x,m_ptTimer[i].y,m_wGameClock);
			DrawUserClock(pDC,m_ptTimer[i].x,m_ptTimer[i].y+27,m_wLeftClock[i]);

			wUserTimer = GetUserTimer(i);
			if ( 0 < wUserTimer )
				DrawUserTimer( pDC, m_ptReady[i].x, m_ptReady[i].y, wUserTimer );

			//其他信息
						if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
		}
	}

	//按钮底图
	CImageHandle ButtonBackHandle(&m_ImageButtonBack);
	nYPos=nHeight-m_nYBorder-m_ButtonBackSize.cy-5;
	nXPos=m_UserInfoSize.cx+(nWidth-m_UserInfoSize.cx-m_ButtonBackSize.cx)/2;
	m_ImageButtonBack.BitBlt(pDC->m_hDC,nXPos,nYPos);

	return;
}
示例#13
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageFill,enMode_Spread);
	DrawViewImage(pDC,m_ImageBack,enMode_Centent);

	
	//绘画用户
	TCHAR szBuffer[32];
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);

		///////////////////////////////////////////////
		////test
//		WORD wUserTimer = 30;
//		tagUserData *pUserData = new tagUserData;
//		lstrcpy(pUserData->szName,TEXT("测试玩家"));
//		pUserData->lScore = 10000L;
//		pUserData->cbUserStatus = US_PLAY;
//		m_wLandUser=1;
//		m_bOutBombCount[1]=2;
//		m_bMaxBombCountShow=1;
//		m_bScore[i]=1;
//		m_bPass[i]=true;
//		m_bCardCount[i]=30;
		///////////////////////////////////////////////

		//绘画用户
		if (pUserData!=NULL)
		{
			//用户名字
			pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));
			pDC->SetTextAlign(((i==1)&&(m_bDeasilOrder==true))||((i==3)&&(m_bDeasilOrder==false))?TA_RIGHT:TA_LEFT);
			pDC->TextOut(m_ptName[i].x,m_ptName[i].y,pUserData->szName,lstrlen(pUserData->szName));

			//剩余扑克
			if (pUserData->cbUserStatus>=US_PLAY)
			{
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("(%ld 张)"),m_bCardCount[i]);
				
				if(i==0)	pDC->TextOut(m_ptName[i].x,m_ptName[i].y+20,szBuffer,lstrlen(szBuffer));
				if(i==1)	
				{
#ifdef VIDEO_GAME
					pDC->TextOut(m_ptName[i].x+5,m_ptName[i].y-20,szBuffer,lstrlen(szBuffer));
#else
					pDC->TextOut(m_ptName[i].x+5,m_ptName[i].y+15,szBuffer,lstrlen(szBuffer));
#endif
				}
				if(i==2)	pDC->TextOut(m_ptName[i].x,m_ptName[i].y-20,szBuffer,lstrlen(szBuffer));
				if(i==3)	
				{
#ifdef VIDEO_GAME
					pDC->TextOut(m_ptName[i].x+5,m_ptName[i].y-20,szBuffer,lstrlen(szBuffer));
#else
					pDC->TextOut(m_ptName[i].x,m_ptName[i].y+15,szBuffer,lstrlen(szBuffer));
#endif
				}

				if(m_bMaxBombCountShow)
				{
					//if(i==2 || i== 0){
					if(m_bMaxBombCount[i] !=255){

						//_snprintf(szBuffer,sizeof(szBuffer),TEXT("%s(可以出%ld个炸弹)"),szBuffer, m_bMaxBombCount[i]);
						//炸弹标志
						CImageHandle ImageHandle(&m_ImageBomb);
						m_ImageBomb.AlphaDrawImage(pDC,m_ptBomb[i].x,m_ptBomb[i].y,RGB(255,0,255));

						//设置 DC
						pDC->SetTextColor(RGB(255,255,0));
						pDC->SetTextAlign(TA_LEFT|TA_TOP);

						//炸弹倍数
						TCHAR szBuffer[8];
						_snprintf(szBuffer,sizeof(szBuffer),TEXT("%d"),m_bMaxBombCount[i]-m_bOutBombCount[i]);
						pDC->TextOut(m_ptBomb[i].x+30,m_ptBomb[i].y+10,szBuffer,lstrlen(szBuffer));
					}
					//} 
				}

				//if(m_bMaxBombCountShow){
				//	if(i==1 || i ==3){
				//		if(m_bMaxBombCount[i] ==255){
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("(可以"));
				//		} else{
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("(可以") );
				//		}
				//		pDC->TextOut(m_ptName[i].x,m_ptName[i].y+18+18,szBuffer,lstrlen(szBuffer));
				//		if(m_bMaxBombCount[i] ==255){
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("任意出"));
				//		} else{
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("(出%ld个"), m_bMaxBombCount[i]);
				//		}
				//		pDC->TextOut(m_ptName[i].x,m_ptName[i].y+18+18+18,szBuffer,lstrlen(szBuffer));
				//		if(m_bMaxBombCount[i] ==255){
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("炸弹)"));
				//		} else{
				//			_snprintf(szBuffer,sizeof(szBuffer),TEXT("炸弹)"));
				//		}
				//		pDC->TextOut(m_ptName[i].x,m_ptName[i].y+18+18+18+18,szBuffer,lstrlen(szBuffer));
				//	}
				//}
			}


			//其他信息
			if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
		}
		
	}

	//叫分标志
	CPngImage ImageScore;
	ImageScore.LoadImage(AfxGetInstanceHandle(),TEXT("SCORE"));
	int nXImagePos,nImageWidth=ImageScore.GetWidth(),nImageHeight=ImageScore.GetHeight();
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		if ((m_bScore[i]!=0))
		{
			if ((m_bPass[i]==true)||(m_bScore[i]==255)) nXImagePos=ImageScore.GetWidth()*3/5;
			else nXImagePos=(m_bScore[i]-1)*ImageScore.GetWidth()/5;
			ImageScore.DrawImage(pDC,m_ptScore[i].x,m_ptScore[i].y,nImageWidth/5,nImageHeight,nXImagePos,0);
		}
		if(m_bPass[i]==true)
		{
			if ((m_bPass[i]==true)||(m_bScore[i]==255)) nXImagePos=ImageScore.GetWidth()*4/5;
			else nXImagePos=(m_bScore[i]-1)*ImageScore.GetWidth()/5;
			ImageScore.DrawImage(pDC,m_ptScore[i].x,m_ptScore[i].y,nImageWidth/5,nImageHeight,nXImagePos,0);	
		}
	}

	//test
	//tagUserData *pUserData = new tagUserData;
	//lstrcpy(pUserData->szName,TEXT("测试玩家"));
	//pUserData->lScore = 10000L;
	//pUserData->cbUserStatus = US_READY;


	//庄家位置
	if (m_wLandUser!=INVALID_CHAIR)
	{
		//获取用户
		const tagUserData * pUserData=GetUserInfo(m_wLandUser);
		if (pUserData!=NULL)
		{
			//变量定义
			TCHAR szBuffer[64];
			CPngImage ImageLand;
			ImageLand.LoadImage(AfxGetInstanceHandle(),TEXT("BANKER"));

			//设置 DC
			pDC->SetTextAlign(TA_LEFT|TA_TOP);
			pDC->SetTextColor(RGB(250,250,250));

			//绘画信息
			ImageLand.DrawImage(pDC,m_ptLand[m_wLandUser].x,m_ptLand[m_wLandUser].y);
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("地主:%s"),pUserData->szName);
			pDC->TextOut(m_nXBorder+m_nXFace+10,m_nYBorder+8,szBuffer,lstrlen(szBuffer));
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("倍数:%d 倍"),m_cbLandScore);
			pDC->TextOut(m_nXBorder+m_nXFace+10,m_nYBorder+25,szBuffer,lstrlen(szBuffer));
			DrawUserFace(pDC,pUserData,m_nXBorder+5,m_nYBorder+5,false);
		}
	}

	//炸弹倍数
	//if (m_wBombTime>1)
	//{
	//	//炸弹标志
	//	CImageHandle ImageHandle(&m_ImageBomb);
	//	m_ImageBomb.AlphaDrawImage(pDC,m_nXBorder+5,nHeight-m_nYBorder-m_ImageBomb.GetHeight()-5,RGB(255,0,255));

	//	//设置 DC
	//	pDC->SetTextColor(RGB(250,250,250));
	//	pDC->SetTextAlign(TA_LEFT|TA_TOP);

	//	//炸弹倍数
	//	TCHAR szBuffer[64];
	//	_snprintf(szBuffer,sizeof(szBuffer),TEXT("已出炸弹:%d"),m_wBombTime);
	//	pDC->TextOut(m_nXBorder+m_ImageBomb.GetWidth()+10,nHeight-m_nYBorder-20,szBuffer,lstrlen(szBuffer));
	//}

	//描述信息
	if (m_bLandTitle==true)
	{
		//创建资源
		CFont InfoFont;
		InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

		//设置 DC
		pDC->SetTextColor(RGB(201,229,133));
		pDC->SetTextAlign(TA_CENTER|TA_TOP);
		CFont * pOldFont=pDC->SelectObject(&InfoFont);

		//绘画信息
		pDC->TextOut(nWidth/2,200,"正等待用户叫分");

		//清理资源
		pDC->SelectObject(pOldFont);
		InfoFont.DeleteObject();
	}

	return;
}
示例#14
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageBack,enMode_Spread);
	DrawViewImage(pDC,m_ImageCenter,enMode_Centent);	

	//绘画用户
	TCHAR szBuffer[32];
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);

		/////////////////////////////////////////////////////

		//tagUserData *pUserData = new tagUserData;
		//strcpy( (char*)pUserData->szName, "dkjfdkfjdkfj" );
		//pUserData->cbUserStatus = US_READY;
		//wUserTimer = 10;
		//m_ImageLand.DrawImage(pDC,m_ptLand[i].x,m_ptLand[i].y);
		//m_wBombTime = 2;
		//m_bShowWarming[i]=true;
		//m_bCardCount[i] = 2;
		//m_cbCallScorePhase=5;
		//m_bScore[i] = 3;
		//m_bPass[i]=false;

		//m_wLandUser = 2;
		//m_wBombTime=4;
		///////////////////////////////////////////////////////

		//绘画用户
		if (pUserData!=NULL)
		{
			//用户名字
			pDC->SetTextAlign( ( ( i == 2 && ! m_bDeasilOrder ) || ( i == 0 && m_bDeasilOrder ) ) ? TA_RIGHT : TA_LEFT );
			pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));
			DrawTextString( pDC, pUserData->szName, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_ptName[i].x,m_ptName[i].y );

			//剩余扑克
		//	if (i!=1)
			{
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("剩余:%d 张"),m_bCardCount[i]);
				DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_ptName[i].x,m_ptName[i].y+18 );
			}

			//其他信息
			if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);

			//报牌信息
			if(m_bShowWarming[i])
			{
				//创建资源
				CFont InfoFont;
				InfoFont.CreateFont(-40,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

				//设置 DC
				pDC->SetTextColor(RGB(255,0,0));
				pDC->SetTextAlign(TA_CENTER|TA_TOP);
				CFont * pOldFont=pDC->SelectObject(&InfoFont);

				//绘画信息
				if ( i == 0 || i == 2)
				{
					if ( m_bCardCount[i] == 1)
						m_ImageOnecardWarming.DrawImage(pDC, m_ptWarmingCard[i].x,  m_ptWarmingCard[i].y);
					else if(m_bCardCount[i] == 2 )
						m_ImageTwoCardWarming.DrawImage(pDC, m_ptWarmingCard[i].x,  m_ptWarmingCard[i].y);
				}					


				//清理资源
				pDC->SelectObject(pOldFont);
				InfoFont.DeleteObject();			

			}

			//亮牌信息
			if ( m_bBrightStart[i] )
			{
				BYTE const SECTION_COUNT = 11; 
				INT nInfoWidth = m_ImageScore.GetWidth() / SECTION_COUNT;
				INT nInfoHeight = m_ImageScore.GetHeight();
				INT nXPos = nInfoWidth * 8 ;
				m_ImageScore.DrawImage(pDC, m_ptBrightStart[i].x, m_ptBrightStart[i].y, nInfoWidth, nInfoHeight, nXPos, 0 );
			}
		}
	}

	//显示倍数
	//if ( m_cbCallScorePhase >= CSD_SNATCHLAND && m_cbLandScore > 1 )
	//{
	//	//位置信息
	//	INT const LAND_TIMES_COUNT = 5;
	//	INT nXPos = 0;
	//	INT nNumWidth = m_ImageLandTimes.GetWidth() / LAND_TIMES_COUNT;
	//	INT nNumHeight = m_ImageLandTimes.GetHeight();
	//	if ( m_cbLandScore == 2 ) nXPos = 0;
	//	else if ( m_cbLandScore == 3 ) nXPos = nNumWidth;
	//	else if ( m_cbLandScore == 4 ) nXPos = 2 * nNumWidth;
	//	else if ( m_cbLandScore == 5 ) nXPos = 3 * nNumWidth;

	//	INT nSpace = 10;
	//	INT nXStartPos = ( nWidth - ( 2 * nNumWidth - nSpace ) ) / 2;
	//	INT nYStartPos = 250;

	//	//绘画图片
	//	m_ImageLandTimes.DrawImage( pDC, nXStartPos, nYStartPos, nNumWidth, nNumHeight, nNumWidth * 4, 0 );
	//	m_ImageLandTimes.DrawImage( pDC, nXStartPos+nNumWidth-nSpace, nYStartPos, nNumWidth, nNumHeight, nXPos, 0 );
	//}

	//叫分标志
	int nXImagePos,nImageWidth=m_ImageScore.GetWidth(),nImageHeight=m_ImageScore.GetHeight();
	for (WORD i=0;i<3;i++)
	{
		if ((m_bScore[i]!=0)||(m_bPass[i]==true) || m_bDoubleScore[i]==true)
		{
			BYTE const SECTION_COUNT = 11; 
			if ( m_bPass[i]==true ) nXImagePos=m_ImageScore.GetWidth()*4/SECTION_COUNT;
			else if ( m_bScore[i]==255 && m_cbUserPhase[i] == CSD_SNATCHLAND ) nXImagePos=m_ImageScore.GetWidth()*6/SECTION_COUNT;
			else if ( m_bScore[i]==255 && m_cbUserPhase[i] == CSD_BRIGHTCARD ) nXImagePos=m_ImageScore.GetWidth()*10/SECTION_COUNT;
			else if ( m_bScore[i]==255 ) nXImagePos=m_ImageScore.GetWidth()*3/SECTION_COUNT;
			else if (m_bScore[i]==4) nXImagePos=7*m_ImageScore.GetWidth()/SECTION_COUNT;
			else if ( m_bDoubleScore[i]==true ) nXImagePos=5*m_ImageScore.GetWidth()/SECTION_COUNT;
			else nXImagePos=9*m_ImageScore.GetWidth()/SECTION_COUNT;
			m_ImageScore.DrawImage(pDC,m_ptScore[i].x,m_ptScore[i].y,nImageWidth/SECTION_COUNT,nImageHeight,nXImagePos,0);
		}
	}

	//庄家位置
	if (m_wLandUser!=INVALID_CHAIR && m_cbCallScorePhase == CSD_GAMESTART)
	{
		//获取用户
		const tagUserData * pUserData=GetUserInfo(m_wLandUser);
		if (pUserData!=NULL)
		{
			//变量定义
			TCHAR szBuffer[64];
			INT nXStartPos = m_nXFace + m_nXBorder + 15;
			INT nYStartPos = m_nYBorder+10;
			INT nSpace = 20;

			//设置DC
			pDC->SetTextAlign( DT_LEFT );

			//绘画信息
			m_ImageLand.DrawImage(pDC,m_ptLand[m_wLandUser].x,m_ptLand[m_wLandUser].y);
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("地主:%s"),pUserData->szName);
			DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), nXStartPos,nYStartPos );

			//绘画头像
			DrawUserFace(pDC,pUserData,m_nXBorder+5,m_nYBorder+5,false);

			//叫牌分数
			LONG lScore=m_cbLandScore*m_lBaseScore;
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("底分:%ld "),m_lBaseScore);
			DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), nXStartPos,nYStartPos + nSpace  );

			//翻倍计算
			WORD wDrawTimes=(WORD)m_lBaseScore;
			for (WORD i=1;i<m_cbLandScore;i++) wDrawTimes*=2;

			//总共倍数
			WORD wLandTime = 0;
			if ( m_cbBrightTime != 0 && wDrawTimes == 0 ) wLandTime = m_cbBrightTime;
			else if ( m_cbBrightTime == 0 && wDrawTimes != 0 ) wLandTime = wDrawTimes;
			else if ( m_cbBrightTime != 0 && wDrawTimes != 0 ) wLandTime = m_cbBrightTime * wDrawTimes;
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("倍数:%ld"),wLandTime );
			DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), nXStartPos,nYStartPos + nSpace * 2 );

			//炸弹倍数
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("炸弹翻倍:%d"),m_wBombTime);
			DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), nXStartPos,nYStartPos + nSpace * 3);
		}
	}

	//绘画爆炸
	if (m_bBombEffect==true)
	{
		//加载资源
		CImageHandle HandleBombEffect(&m_ImageBombEffect);

		//绘画效果
		INT nImageHeight=m_ImageBombEffect.GetHeight();
		INT nImageWidth=m_ImageBombEffect.GetWidth()/BOMB_EFFECT_COUNT;
		m_ImageBombEffect.AlphaDrawImage(pDC,(nWidth-nImageWidth)/2,0,nImageWidth,nImageHeight,
			nImageWidth*(m_cbBombFrameIndex%BOMB_EFFECT_COUNT),0,RGB(255,0,255));
	}

	//描述信息
	if (m_bLandTitle==true)
	{
		//创建资源
		CFont InfoFont;
		InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

		//设置 DC
		pDC->SetTextColor(RGB(201,229,133));
		pDC->SetTextAlign(TA_CENTER|TA_TOP);
		CFont * pOldFont=pDC->SelectObject(&InfoFont);

		//绘画信息
		pDC->TextOut(nWidth/2,200,"正等待用户叫分");

		//清理资源
		pDC->SelectObject(pOldFont);
		InfoFont.DeleteObject();
	}

	//托管标识
	for ( WORD wChairID = 0; wChairID < GAME_PLAYER; ++wChairID ) {
		
		const tagUserData * pUserData=GetUserInfo( wChairID );
		if ( pUserData == NULL ) m_bUserTrustee[ wChairID ] = false;

		if ( m_bUserTrustee[ wChairID ] ) {
			if ( wChairID == 1 )
				m_ImageUserTrustee.DrawImage( pDC, m_ptLand[ wChairID ].x + 40, m_ptLand[ wChairID ].y - 1 );
			else if ( wChairID == 0 && !m_bDeasilOrder || wChairID == 2 && m_bDeasilOrder )
				m_ImageUserTrustee.DrawImage( pDC, m_ptFace[ wChairID ].x + m_nXFace + 8, m_ptFace[ wChairID ].y + m_nYFace -
				m_ImageUserTrustee.GetHeight() + 3 );
			else 
				m_ImageUserTrustee.DrawImage( pDC, m_ptFace[ wChairID ].x - m_nXFace - 8, m_ptFace[ wChairID ].y + m_nYFace -
				m_ImageUserTrustee.GetHeight() + 3 );
		}
	}

	//绘画倍数
	if ( m_bShowLandTime ) DrawLandTime(pDC, nWidth, nHeight);

	return;
}
示例#15
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageBack,enMode_Spread);
	DrawViewImage(pDC,m_ImageCenter,enMode_Centent);

	CImageHandle HandleHeadBg(&m_ImageHeadBg);
	

	//绘画用户
	TCHAR szBuffer[32];
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);

		//绘画用户
		if (pUserData!=NULL)
		{
			//m_ImageHeadBg.BitBlt(pDC->m_hDC,m_ptFace[i].x-2,m_ptFace[i].y-2);
			//用户名字
			pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));
			pDC->SetTextAlign(((i==0)&&(m_bDeasilOrder==true))||((i==2)&&(m_bDeasilOrder==false))?TA_RIGHT:TA_LEFT);
			pDC->TextOut(m_ptName[i].x,m_ptName[i].y,pUserData->szName,lstrlen(pUserData->szName));

			//剩余扑克
			if (pUserData->cbUserStatus>=US_PLAY)
			{
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("(%ld 张)"),m_bCardCount[i]);
				pDC->TextOut(m_ptName[i].x,m_ptName[i].y+18,szBuffer,lstrlen(szBuffer));
			}

			//其他信息
			if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
		}
	}

	////叫分标志
	//CImageHandle ImageHnadleScore(&m_ImageScore);
	//int nXImagePos,nImageWidth=m_ImageScore.GetWidth(),nImageHeight=m_ImageScore.GetHeight();
	//for (WORD i=0;i<3;i++)
	//{
	//	if ((m_bScore[i]!=0)||(m_bPass[i]==true))
	//	{
	//		if ((m_bPass[i]==true)||(m_bScore[i]==255)) nXImagePos=m_ImageScore.GetWidth()*3/4;
	//		else nXImagePos=(m_bScore[i]-1)*m_ImageScore.GetWidth()/4;
	//		m_ImageScore.AlphaDrawImage(pDC,m_ptScore[i].x,m_ptScore[i].y,nImageWidth/4,nImageHeight,nXImagePos,0,RGB(255,0,255));
	//	}
	//}

	////庄家位置
	//if (m_wLandUser!=INVALID_CHAIR)
	//{
	//	//获取用户
	//	const tagUserData * pUserData=GetUserInfo(m_wLandUser);
	//	if (pUserData!=NULL)
	//	{
	//		//变量定义
	//		TCHAR szBuffer[64];
	//		CImageHandle ImageHandleLand(&m_ImageLand);

	//		//设置 DC
	//		pDC->SetTextAlign(TA_LEFT|TA_TOP);
	//		pDC->SetTextColor(RGB(250,250,250));

	//		//绘画信息
	//		m_ImageLand.AlphaDrawImage(pDC,m_ptLand[m_wLandUser].x,m_ptLand[m_wLandUser].y,RGB(255,0,255));
	//		_snprintf(szBuffer,sizeof(szBuffer),TEXT("地主:%s"),pUserData->szName);
	//		pDC->TextOut(m_nXBorder+m_nXFace+10,m_nYBorder+8,szBuffer,lstrlen(szBuffer));
	//		_snprintf(szBuffer,sizeof(szBuffer),TEXT("底分:%d 分"),m_cbLandScore);
	//		pDC->TextOut(m_nXBorder+m_nXFace+10,m_nYBorder+25,szBuffer,lstrlen(szBuffer));
	//		DrawUserFace(pDC,pUserData->wFaceID,m_nXBorder+5,m_nYBorder+5,false);
	//	}
	//}

	////炸弹倍数
	//if (m_wBombTime>1)
	//{
	//	//炸弹标志
	//	CImageHandle ImageHandle(&m_ImageBomb);
	//	m_ImageBomb.AlphaDrawImage(pDC,m_nXBorder+5,nHeight-m_nYBorder-m_ImageBomb.GetHeight()-5,RGB(255,0,255));

	//	//设置 DC
	//	pDC->SetTextColor(RGB(250,250,250));
	//	pDC->SetTextAlign(TA_LEFT|TA_TOP);

	//	//炸弹倍数
	//	TCHAR szBuffer[64];
	//	_snprintf(szBuffer,sizeof(szBuffer),TEXT("炸弹翻倍:%d"),m_wBombTime);
	//	pDC->TextOut(m_nXBorder+m_ImageBomb.GetWidth()+10,nHeight-m_nYBorder-20,szBuffer,lstrlen(szBuffer));
	//}

	////描述信息
	//if (m_bLandTitle==true)
	//{
	//	//创建资源
	//	CFont InfoFont;
	//	InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

	//	//设置 DC
	//	pDC->SetTextColor(RGB(201,229,133));
	//	pDC->SetTextAlign(TA_CENTER|TA_TOP);
	//	CFont * pOldFont=pDC->SelectObject(&InfoFont);

	//	//绘画信息
	//	pDC->TextOut(nWidth/2,200,"正等待用户叫分");

	//	//清理资源
	//	pDC->SelectObject(pOldFont);
	//	InfoFont.DeleteObject();
	//}

	return;
}
示例#16
0
文件: sv_main.c 项目: darkshade9/aq2w
/*
 * Svc_Connect
 *
 * A connection request that did not come from the master.
 */
static void Svc_Connect(void) {
	char user_info[MAX_USER_INFO_STRING];
	sv_client_t *cl, *client;
	net_addr_t addr;
	int version;
	byte qport;
	unsigned int challenge;
	int i;

	Com_Debug("Svc_Connect()\n");

	addr = net_from;

	version = atoi(Cmd_Argv(1));

	// resolve protocol
	if (version != PROTOCOL) {
		Netchan_OutOfBandPrint(NS_SERVER, addr,
				"print\nServer is version %d.\n", PROTOCOL);
		return;
	}

	qport = strtoul(Cmd_Argv(2), NULL, 0) & 0xff;

	challenge = strtoul(Cmd_Argv(3), NULL, 0);

	//copy user_info, leave room for ip stuffing
	strncpy(user_info, Cmd_Argv(4), sizeof(user_info) - 1 - 25);
	user_info[sizeof(user_info) - 1] = 0;

	if (*user_info == '\0') { // catch empty user_info
		Com_Print("Empty user_info from %s\n", Net_NetaddrToString(addr));
		Netchan_OutOfBandPrint(NS_SERVER, addr, "print\nConnection refused.\n");
		return;
	}

	if (strchr(user_info, '\xFF')) { // catch end of message in string exploit
		Com_Print("Illegal user_info contained xFF from %s\n",
				Net_NetaddrToString(addr));
		Netchan_OutOfBandPrint(NS_SERVER, addr, "print\nConnection refused.\n");
		return;
	}

	if (strlen(GetUserInfo(user_info, "ip"))) { // catch spoofed ips
		Com_Print("Illegal user_info contained ip from %s\n",
				Net_NetaddrToString(addr));
		Netchan_OutOfBandPrint(NS_SERVER, addr, "print\nConnection refused.\n");
		return;
	}

	if (!ValidateUserInfo(user_info)) { // catch otherwise invalid user_info
		Com_Print("Invalid user_info from %s\n", Net_NetaddrToString(addr));
		Netchan_OutOfBandPrint(NS_SERVER, addr, "print\nConnection refused.\n");
		return;
	}

	// force the ip so the game can filter on it
	SetUserInfo(user_info, "ip", Net_NetaddrToString(addr));

	// enforce a valid challenge to avoid denial of service attack
	for (i = 0; i < MAX_CHALLENGES; i++) {
		if (Net_CompareClientNetaddr(addr, svs.challenges[i].addr)) {
			if (challenge == svs.challenges[i].challenge) {
				svs.challenges[i].challenge = 0;
				break; // good
			}
			Netchan_OutOfBandPrint(NS_SERVER, addr, "print\nBad challenge.\n");
			return;
		}
	}
	if (i == MAX_CHALLENGES) {
		Netchan_OutOfBandPrint(NS_SERVER, addr,
				"print\nNo challenge for address.\n");
		return;
	}

	// resolve the client slot
	client = NULL;

	// first check for an ungraceful reconnect (client crashed, perhaps)
	for (i = 0, cl = svs.clients; i < sv_max_clients->integer; i++, cl++) {

		const net_chan_t *ch = &cl->netchan;

		if (cl->state == SV_CLIENT_FREE) // not in use, not interested
			continue;

		// the base address and either the qport or real port must match
		if (Net_CompareClientNetaddr(addr, ch->remote_address) &&
				(qport == ch->qport || ch->remote_address.port == addr.port)) {
			client = cl;
			break;
		}
	}

	// otherwise, treat as a fresh connect to a new slot
	if (!client) {
		for (i = 0, cl = svs.clients; i < sv_max_clients->integer; i++, cl++) {
			if (cl->state == SV_CLIENT_FREE) { // we have a free one
				client = cl;
				break;
			}
		}
	}

	// no soup for you, next!!
	if (!client) {
		Netchan_OutOfBandPrint(NS_SERVER, addr, "print\nServer is full.\n");
		Com_Debug("Rejected a connection.\n");
		return;
	}

	// give the game a chance to reject this connection or modify the user_info
	if (!(svs.game->ClientConnect(client->edict, user_info))) {

		if (*GetUserInfo(user_info, "rejmsg")) {
			Netchan_OutOfBandPrint(NS_SERVER, addr,
					"print\n%s\nConnection refused.\n",
					GetUserInfo(user_info, "rejmsg"));
		} else {
			Netchan_OutOfBandPrint(NS_SERVER, addr,
					"print\nConnection refused.\n");
		}

		Com_Debug("Game rejected a connection.\n");
		return;
	}

	// parse some info from the info strings
	strncpy(client->user_info, user_info, sizeof(client->user_info) - 1);
	Sv_UserInfoChanged(client);

	// send the connect packet to the client
	Netchan_OutOfBandPrint(NS_SERVER, addr, "client_connect %s",
			sv_download_url->string);

	Netchan_Setup(NS_SERVER, &client->netchan, addr, qport);

	Sb_Init(&client->datagram, client->datagram_buf,
			sizeof(client->datagram_buf));
	client->datagram.allow_overflow = true;

	client->last_message = svs.real_time; // don't timeout

	client->state = SV_CLIENT_CONNECTED;
}
示例#17
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageBack,enMode_Spread);
	DrawViewImage(pDC,m_ImageCenter,enMode_Centent);

	//绘画用户
	TCHAR szBuffer[32];
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);

		//绘画用户
		if (pUserData!=NULL)
		{
			//用户名字
			pDC->SetTextAlign( ( ( i == 3 && ! m_bDeasilOrder ) || ( i == 0 && m_bDeasilOrder ) ) ? TA_RIGHT : TA_LEFT );
			pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));
			DrawTextString( pDC, pUserData->szName, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_ptName[i].x,m_ptName[i].y );

			//剩余扑克
			{
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("剩余:%d 张"),m_bCardCount[i]);
				DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_ptName[i].x,m_ptName[i].y+18 );
			}

			//CImageHandle HandleCard(&m_Imagetime);
			//m_Imagetime.AlphaDrawImage(pDC,m_ptTimer[i].x,m_ptTimer[i].y,/*nWidth/2-465, nHeight/2-355,*/RGB(255,0,255));

			//其他信息
			if (wUserTimer!=0)
			{ 
				DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
				//CImageHandle HandleCard(&m_Imagetimech);
				//for(int i=wUserTimer-2; i>=0; i--)
				//m_Imagetimech.AlphaDrawImage(pDC,nWidth/2-396+(i*10), nHeight/2-350,RGB(255,0,255));
			}
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);

			//托管标识
			if ( m_bUserTrustee[ i ] ) {
			if ( i == ME_VIEW_CHAIR )
				m_ImageUserTrustee.DrawImage( pDC, m_ptLand[ i ].x + 40, m_ptLand[ i ].y - 1 );
			else if ( i == 0 )
				m_ImageUserTrustee.DrawImage( pDC, m_ptLand[ i ].x + 40, m_ptFace[ i ].y + m_nYFace -
				m_ImageUserTrustee.GetHeight() + 3 );
			else if ( i == 1 )
				m_ImageUserTrustee.DrawImage( pDC, m_ptFace[ i ].x + m_nXFace + 8, m_ptFace[ i ].y + m_nYFace -
				m_ImageUserTrustee.GetHeight() + 3 );
			else
				m_ImageUserTrustee.DrawImage( pDC, m_ptFace[ i ].x - m_nXFace - 8, m_ptFace[ i ].y + m_nYFace -
				m_ImageUserTrustee.GetHeight() + 3 );
		}
		}
	}

	//叫分标志
	int nXImagePos,nImageWidth=m_ImageScore.GetWidth(),nImageHeight=m_ImageScore.GetHeight();
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		if ((m_bScore[i]!=0)||(m_bPass[i]==true))
		{
			if ( m_bPass[i]==true ) nXImagePos=m_ImageScore.GetWidth()*4/5;
			else if ( m_bScore[i]==255 ) nXImagePos=m_ImageScore.GetWidth()*3/5;
			else nXImagePos=(m_bScore[i]-1)*m_ImageScore.GetWidth()/5;
			m_ImageScore.DrawImage(pDC,m_ptScore[i].x,m_ptScore[i].y,nImageWidth/5,nImageHeight,nXImagePos,0);
		}
	}

	//庄家位置
	if (m_wLandUser!=INVALID_CHAIR)
	{
		//获取用户
		const tagUserData * pUserData=GetUserInfo(m_wLandUser);
		//tagUserData *pUserData = new tagUserData;
		//strcpy( (char*)pUserData->szName, "dkjfdkfjdkfj" );
		if (pUserData!=NULL)
		{
			//变量定义
			TCHAR szBuffer[64];

			//设置 DC
			pDC->SetTextAlign(TA_LEFT|TA_TOP);
			pDC->SetTextColor(RGB(250,250,250));

			//扑克高度
			CRect CardRect;
			//m_BackCardControl.GetWindowRect( &CardRect );
			ScreenToClient( &CardRect );

			//绘画信息
			m_ImageLand.DrawImage(pDC,m_ptLand[m_wLandUser].x,m_ptLand[m_wLandUser].y);
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("地主:%s"),pUserData->szName);
			DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_nXBorder+10,CardRect.bottom+10 );

			//绘画头像
		//	DrawUserFace(pDC,pUserData->wFaceID,m_nXBorder+5,m_nYBorder+5,false);

			//叫牌分数
			LONG lScore=m_cbLandScore*m_lBaseScore;
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("分数:%ld 分"),lScore);
			DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_nXBorder+10,CardRect.bottom+30 );
		}
	}

	//绘画爆炸
	if (m_bBombEffect==true)
	{
		//加载资源
		CImageHandle HandleBombEffect(&m_ImageBombEffect);

		//绘画效果
		INT nImageHeight=m_ImageBombEffect.GetHeight();
		INT nImageWidth=m_ImageBombEffect.GetWidth()/BOMB_EFFECT_COUNT;
		m_ImageBombEffect.AlphaDrawImage(pDC,(nWidth-nImageWidth)/2,0,nImageWidth,nImageHeight,
			nImageWidth*(m_cbBombFrameIndex%BOMB_EFFECT_COUNT),0,RGB(255,0,255));
	}

	//炸弹倍数
	if (m_wBombTime>1)
	{
		//扑克高度
		CRect CardRect;
		//m_BackCardControl.GetWindowRect( &CardRect );
		ScreenToClient( &CardRect );

		//炸弹标志
		CImageHandle ImageHandle(&m_ImageBomb);
		m_ImageBomb.AlphaDrawImage(pDC,m_nXBorder+5,50+CardRect.bottom,RGB(255,0,255));

		//设置 DC
		pDC->SetTextColor(RGB(250,250,250));
		pDC->SetTextAlign(TA_LEFT|TA_TOP);

		//炸弹倍数
		TCHAR szBuffer[64];
		_snprintf(szBuffer,sizeof(szBuffer),TEXT("炸弹翻倍:%d"),m_wBombTime);
		DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_nXBorder+m_ImageBomb.GetWidth()+10,CardRect.bottom+60 );
	}

	//描述信息
	if (m_bLandTitle==true)
	{
		//创建资源
		CFont InfoFont;
		InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

		//设置 DC
		pDC->SetTextColor(RGB(201,229,133));
		pDC->SetTextAlign(TA_CENTER|TA_TOP);
		CFont * pOldFont=pDC->SelectObject(&InfoFont);

		//绘画信息
		pDC->TextOut(nWidth/2,200,"正等待用户叫分");

		//清理资源
		pDC->SelectObject(pOldFont);
		InfoFont.DeleteObject();
	}

	return;
}